Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the "break with label" example more illustrative #1830

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/control-flow-basics/break-continue/labels.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ to break out of nested loops:
```rust,editable
fn main() {
let s = [[5, 6, 7], [8, 9, 10], [21, 15, 32]];
let mut found = false;
let mut elements_searched = 0;
let target_value = 10;
'outer: for i in 0..=2 {
for j in 0..=2 {
elements_searched += 1;
if s[i][j] == target_value {
found = true;
break 'outer;
}
}
}
print!("{}", found)
print!("elements searched: {}", elements_searched);
mgeisler marked this conversation as resolved.
Show resolved Hide resolved
}
```

Expand Down