rust/tests/ui/unboxed-closures/unboxed-closures-blanket-fn.rs

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

28 lines
388 B
Rust
Raw Normal View History

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