mirror of
https://github.com/google/comprehensive-rust.git
synced 2025-05-16 23:55:42 +02:00
As mentioned in #2478, this cleans up the code blocks when all that is needed is a trivial debug print statement. Only making changes to Day 1 morning session so that I can get feedback before proceeding with the rest of the course. --------- Co-authored-by: Eric Githinji <egithinji@google.com>
424 B
424 B
loop
The loop
statement just
loops forever, until a break
.
fn main() {
let mut i = 0;
loop {
i += 1;
dbg!(i);
if i > 100 {
break;
}
}
}
- The
loop
statement works like awhile true
loop. Use it for things like servers which will serve connections forever.