diff options
Diffstat (limited to 'src/doc/book/listings/ch19-advanced-features/listing-19-25')
3 files changed, 30 insertions, 0 deletions
diff --git a/src/doc/book/listings/ch19-advanced-features/listing-19-25/Cargo.lock b/src/doc/book/listings/ch19-advanced-features/listing-19-25/Cargo.lock new file mode 100644 index 000000000..c0c98a79c --- /dev/null +++ b/src/doc/book/listings/ch19-advanced-features/listing-19-25/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "types-example" +version = "0.1.0" + diff --git a/src/doc/book/listings/ch19-advanced-features/listing-19-25/Cargo.toml b/src/doc/book/listings/ch19-advanced-features/listing-19-25/Cargo.toml new file mode 100644 index 000000000..a2ae20c77 --- /dev/null +++ b/src/doc/book/listings/ch19-advanced-features/listing-19-25/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "types-example" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/src/doc/book/listings/ch19-advanced-features/listing-19-25/src/main.rs b/src/doc/book/listings/ch19-advanced-features/listing-19-25/src/main.rs new file mode 100644 index 000000000..af35bed2c --- /dev/null +++ b/src/doc/book/listings/ch19-advanced-features/listing-19-25/src/main.rs @@ -0,0 +1,18 @@ +fn main() { + // ANCHOR: here + type Thunk = Box<dyn Fn() + Send + 'static>; + + let f: Thunk = Box::new(|| println!("hi")); + + fn takes_long_type(f: Thunk) { + // --snip-- + } + + fn returns_long_type() -> Thunk { + // --snip-- + // ANCHOR_END: here + Box::new(|| ()) + // ANCHOR: here + } + // ANCHOR_END: here +} |