From 333e97d7ed5c1ca01f3f2330ae556fa456d8ab37 Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Sun, 24 Mar 2024 10:52:00 +0000 Subject: [PATCH] Make scoped thread examples consistent This is a followup to #1020. --- src/concurrency/threads/scoped.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/concurrency/threads/scoped.md b/src/concurrency/threads/scoped.md index 89d782bbf4ad..339645196f88 100644 --- a/src/concurrency/threads/scoped.md +++ b/src/concurrency/threads/scoped.md @@ -26,15 +26,18 @@ However, you can use a [scoped thread][1] for this: ```rust,editable use std::thread; -fn main() { +fn foo() { let s = String::from("Hello"); - thread::scope(|scope| { scope.spawn(|| { println!("Length: {}", s.len()); }); }); } + +fn main() { + foo(); +} ``` [1]: https://doc.rust-lang.org/std/thread/fn.scope.html