summaryrefslogtreecommitdiffstats
path: root/src/doc/book/listings/ch13-functional-features/listing-13-06
diff options
context:
space:
mode:
Diffstat (limited to 'src/doc/book/listings/ch13-functional-features/listing-13-06')
-rw-r--r--src/doc/book/listings/ch13-functional-features/listing-13-06/Cargo.toml8
-rw-r--r--src/doc/book/listings/ch13-functional-features/listing-13-06/src/main.rs10
2 files changed, 18 insertions, 0 deletions
diff --git a/src/doc/book/listings/ch13-functional-features/listing-13-06/Cargo.toml b/src/doc/book/listings/ch13-functional-features/listing-13-06/Cargo.toml
new file mode 100644
index 000000000..8085ade0f
--- /dev/null
+++ b/src/doc/book/listings/ch13-functional-features/listing-13-06/Cargo.toml
@@ -0,0 +1,8 @@
+[package]
+name = "closure-example"
+version = "0.1.0"
+edition = "2021"
+
+# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
+
+[dependencies]
diff --git a/src/doc/book/listings/ch13-functional-features/listing-13-06/src/main.rs b/src/doc/book/listings/ch13-functional-features/listing-13-06/src/main.rs
new file mode 100644
index 000000000..2c8e18c9f
--- /dev/null
+++ b/src/doc/book/listings/ch13-functional-features/listing-13-06/src/main.rs
@@ -0,0 +1,10 @@
+use std::thread;
+
+fn main() {
+ let list = vec![1, 2, 3];
+ println!("Before defining closure: {:?}", list);
+
+ thread::spawn(move || println!("From thread: {:?}", list))
+ .join()
+ .unwrap();
+}