Skip to content

Commit c48bca9

Browse files
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.
1 parent 8819d3e commit c48bca9

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/flow_control/for.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ fn main() {
8080
data is provided. Once the collection has been consumed it is no longer
8181
available for reuse as it has been 'moved' within the loop.
8282

83-
```rust,editable,ignore,mdbook-runnable
83+
```rust,editable
8484
fn main() {
8585
let names = vec!["Bob", "Frank", "Ferris"];
8686
@@ -91,8 +91,9 @@ fn main() {
9191
}
9292
}
9393
94-
println!("names: {:?}", names);
95-
// FIXME ^ Comment out this line
94+
// `names` has been 'moved' and can no longer be used.
95+
// Try uncommenting the line below to see the compiler error:
96+
// println!("names: {:?}", names);
9697
}
9798
```
9899

0 commit comments

Comments
 (0)