rust/src/test/run-pass/unsized-locals/box-fnonce.rs

9 lines
164 B
Rust
Raw Normal View History

2018-10-28 01:28:47 -05:00
fn call_it<T>(f: Box<dyn FnOnce() -> T>) -> T {
f()
}
fn main() {
let s = "hello".to_owned();
assert_eq!(&call_it(Box::new(|| s)) as &str, "hello");
}