From ad7ef2e50aaa8d43e022b56a4d59ba92fe6ebcda Mon Sep 17 00:00:00 2001 From: Martin Geisler Date: Fri, 18 Oct 2024 03:04:44 -0400 Subject: [PATCH] Make scoped thread examples consistent (#2444) 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 89d782bbf4a..339645196f8 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