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
217 B
Rust
Raw Normal View History

// run-pass
2020-03-27 15:56:19 -05:00
#![allow(unused_braces)]
fn foo(i: isize) -> isize { i + 1 }
2015-01-02 16:32:54 -06: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);
}