rust/tests/ui/functions-closures/closure-inference.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

12 lines
218 B
Rust
Raw Normal View History

//@ run-pass
2020-03-28 04:56:19 +08:00
#![allow(unused_braces)]
fn foo(i: isize) -> isize { i + 1 }
2015-01-03 06:32:54 +08:00
fn apply<A, F>(f: F, v: A) -> A where F: FnOnce(A) -> A { f(v) }
pub fn main() {
let f = {|i| foo(i)};
assert_eq!(apply(f, 2), 3);
}