]> git.lizzy.rs Git - rust.git/blob - tests/ui/unboxed-closures/unboxed-closures-blanket-fn.rs
Auto merge of #107054 - petrochenkov:effvisdoc3, r=GuillaumeGomez
[rust.git] / tests / ui / unboxed-closures / unboxed-closures-blanket-fn.rs
1 // run-pass
2 #![allow(unused_variables)]
3 // Test that you can supply `&F` where `F: Fn()`.
4
5 #![feature(lang_items)]
6
7 fn a<F:Fn() -> i32>(f: F) -> i32 {
8     f()
9 }
10
11 fn b(f: &dyn Fn() -> i32) -> i32 {
12     a(f)
13 }
14
15 fn c<F:Fn() -> i32>(f: &F) -> i32 {
16     a(f)
17 }
18
19 fn main() {
20     let z: isize = 7;
21
22     let x = b(&|| 22);
23     assert_eq!(x, 22);
24
25     let x = c(&|| 22);
26     assert_eq!(x, 22);
27 }