1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-05-16 23:55:42 +02:00
Eric Githinji 0daab179e9
Use dbg! instead of println! in Day 1 mng session (#2652)
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>
2025-02-24 14:12:56 +00:00

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 a while true loop. Use it for things like servers which will serve connections forever.