File tree Expand file tree Collapse file tree 4 files changed +39
-39
lines changed
Expand file tree Collapse file tree 4 files changed +39
-39
lines changed Original file line number Diff line number Diff line change 3232- [ Control Flow Basics] ( control-flow-basics.md )
3333 - [ Conditionals] ( control-flow-basics/conditionals.md )
3434 - [ Loops] ( control-flow-basics/loops.md )
35+ - [ ` for ` ] ( control-flow-basics/loops/for.md )
36+ - [ ` loop ` ] ( control-flow-basics/loops/loop.md )
3537 - [ ` break ` and ` continue ` ] ( control-flow-basics/break-continue.md )
3638 - [ Blocks and Scopes] ( control-flow-basics/blocks-and-scopes.md )
3739 - [ Functions] ( control-flow-basics/functions.md )
Original file line number Diff line number Diff line change @@ -22,42 +22,3 @@ fn main() {
2222 println!("Final x: {x}");
2323}
2424```
25-
26- ## ` for `
27-
28- The [ ` for ` loop] ( https://doc.rust-lang.org/std/keyword.for.html ) iterates over
29- ranges of values:
30-
31- ``` rust,editable
32- fn main() {
33- for x in 1..5 {
34- println!("x: {x}");
35- }
36- }
37- ```
38-
39- ## ` loop `
40-
41- The [ ` loop ` statement] ( https://doc.rust-lang.org/std/keyword.loop.html ) just
42- loops forever, until a ` break ` .
43-
44- ``` rust,editable
45- fn main() {
46- let mut i = 0;
47- loop {
48- i += 1;
49- println!("{i}");
50- if i > 100 {
51- break;
52- }
53- }
54- }
55- ```
56-
57- <details >
58-
59- - We will discuss iteration later; for now, just stick to range expressions.
60- - Note that the ` for ` loop only iterates to ` 4 ` . Show the ` 1..=5 ` syntax for an
61- inclusive range.
62-
63- </details >
Original file line number Diff line number Diff line change 1+ # ` for `
2+
3+ The [ ` for ` loop] ( https://doc.rust-lang.org/std/keyword.for.html ) iterates over
4+ ranges of values:
5+
6+ ``` rust,editable
7+ fn main() {
8+ for x in 1..5 {
9+ println!("x: {x}");
10+ }
11+ }
12+ ```
13+
14+ <details >
15+
16+ - We will discuss iteration later; for now, just stick to range expressions.
17+ - Note that the ` for ` loop only iterates to ` 4 ` . Show the ` 1..=5 ` syntax for an
18+ inclusive range.
19+
20+ </details >
Original file line number Diff line number Diff line change 1+ # ` loop `
2+
3+ The [ ` loop ` statement] ( https://doc.rust-lang.org/std/keyword.loop.html ) just
4+ loops forever, until a ` break ` .
5+
6+ ``` rust,editable
7+ fn main() {
8+ let mut i = 0;
9+ loop {
10+ i += 1;
11+ println!("{i}");
12+ if i > 100 {
13+ break;
14+ }
15+ }
16+ }
17+ ```
You can’t perform that action at this time.
0 commit comments