rust/tests/ui/closures/old-closure-fn-coerce.rs

12 lines
240 B
Rust
Raw Normal View History

// run-pass
2020-03-27 15:56:19 -05:00
#![allow(unused_braces)]
fn force<F>(f: F) -> isize where F: FnOnce() -> isize { return f(); }
2015-01-02 16:32:54 -06:00
pub fn main() {
fn f() -> isize { return 7; }
assert_eq!(force(f), 7);
let g = {||force(f)};
assert_eq!(g(), 7);
}