rust/tests/run-pass/fn_ptr_as_closure_trait_object.rs

16 lines
306 B
Rust
Raw Normal View History

2017-02-07 07:22:20 -06:00
fn foo() {}
fn bar(u: u32) { assert_eq!(u, 42); }
fn baa(u: u32, f: f32) {
assert_eq!(u, 42);
assert_eq!(f, 3.141);
}
fn main() {
let f: &Fn() = &(foo as fn());
f();
let f: &Fn(u32) = &(bar as fn(u32));
f(42);
let f: &Fn(u32, f32) = &(baa as fn(u32, f32));
f(42, 3.141);
}