trpl-zh-cn/listings/ch20-advanced-features/listing-20-24/src/main.rs

17 lines
384 B
Rust
Raw Normal View History

2022-02-06 16:43:51 +08:00
fn main() {
// ANCHOR: here
let f: Box<dyn Fn() + Send + 'static> = Box::new(|| println!("hi"));
fn takes_long_type(f: Box<dyn Fn() + Send + 'static>) {
// --snip--
}
fn returns_long_type() -> Box<dyn Fn() + Send + 'static> {
// --snip--
// ANCHOR_END: here
Box::new(|| ())
// ANCHOR: here
}
// ANCHOR_END: here
}