2019-07-26 16:54:25 -05:00
|
|
|
// run-pass
|
|
|
|
|
2018-11-03 23:47:10 -05:00
|
|
|
trait Foo: Fn(i32) -> i32 + Send {}
|
2018-10-11 19:50:03 -05:00
|
|
|
|
2018-11-03 23:47:10 -05:00
|
|
|
impl<T: ?Sized + Fn(i32) -> i32 + Send> Foo for T {}
|
2018-10-11 19:50:03 -05:00
|
|
|
|
2019-05-28 13:47:21 -05:00
|
|
|
fn wants_foo(f: Box<dyn Foo>) -> i32 {
|
2018-11-03 23:47:10 -05:00
|
|
|
f(42)
|
|
|
|
}
|
2018-10-24 19:03:25 -05:00
|
|
|
|
2018-11-03 23:47:10 -05:00
|
|
|
fn main() {
|
|
|
|
let f = Box::new(|x| x);
|
|
|
|
assert_eq!(wants_foo(f), 42);
|
2018-10-11 19:50:03 -05:00
|
|
|
}
|