2018-08-30 07:18:55 -05:00
|
|
|
// run-pass
|
2018-09-25 16:51:35 -05:00
|
|
|
#![allow(unused_variables)]
|
2015-03-31 11:09:24 -05:00
|
|
|
// Test that you can supply `&F` where `F: Fn()`.
|
|
|
|
|
2016-07-13 09:07:11 -05:00
|
|
|
#![feature(lang_items)]
|
2015-03-31 11:09:24 -05:00
|
|
|
|
|
|
|
fn a<F:Fn() -> i32>(f: F) -> i32 {
|
|
|
|
f()
|
|
|
|
}
|
|
|
|
|
2019-05-28 13:47:21 -05:00
|
|
|
fn b(f: &dyn Fn() -> i32) -> i32 {
|
2015-03-31 11:09:24 -05: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);
|
|
|
|
}
|