From c48bca9bdd43ae5e32c4d96935269d023a0bc80f Mon Sep 17 00:00:00 2001 From: streamatron/ragebaiter Date: Tue, 31 Mar 2026 18:40:24 -0700 Subject: [PATCH] fix: correct into_iter() example to compile properly (#1904) The into_iter() example previously used `println!("names: {:?}", names)` after the collection was consumed, causing a compilation error. Commented out the offending line with an explanation and removed the `ignore` flag so the example is now compilable and runnable. --- src/flow_control/for.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/flow_control/for.md b/src/flow_control/for.md index f457529df6..1beab9261c 100644 --- a/src/flow_control/for.md +++ b/src/flow_control/for.md @@ -80,7 +80,7 @@ fn main() { data is provided. Once the collection has been consumed it is no longer available for reuse as it has been 'moved' within the loop. -```rust,editable,ignore,mdbook-runnable +```rust,editable fn main() { let names = vec!["Bob", "Frank", "Ferris"]; @@ -91,8 +91,9 @@ fn main() { } } - println!("names: {:?}", names); - // FIXME ^ Comment out this line + // `names` has been 'moved' and can no longer be used. + // Try uncommenting the line below to see the compiler error: + // println!("names: {:?}", names); } ```