2018-08-30 14:18:55 +02:00
|
|
|
// run-pass
|
2018-09-25 23:51:35 +02:00
|
|
|
#![allow(unused_variables)]
|
2015-03-31 12:09:24 -04:00
|
|
|
// Test that you can supply `&F` where `F: Fn()`.
|
|
|
|
|
2016-07-13 17:07:11 +03:00
|
|
|
#![feature(lang_items)]
|
2015-03-31 12:09:24 -04:00
|
|
|
|
|
|
|
fn a<F:Fn() -> i32>(f: F) -> i32 {
|
|
|
|
f()
|
|
|
|
}
|
|
|
|
|
2019-05-28 14:47:21 -04:00
|
|
|
fn b(f: &dyn Fn() -> i32) -> i32 {
|
2015-03-31 12:09:24 -04:00
|
|
|
a(f)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn c<F:Fn() -> i32>(f: &F) -> i32 {
|
|
|
|
a(f)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let z: isize = 7;
|
|
|
|
|
|
|
|
let x = b(&|| 22);
|
|
|
|
assert_eq!(x, 22);
|
|
|
|
|
|
|
|
let x = c(&|| 22);
|
|
|
|
assert_eq!(x, 22);
|
|
|
|
}
|