What Is the Difference Between loop and while true in Rust?

Use `loop` for idiomatic infinite repetition in Rust, as `while true` is functionally identical but less explicit.

The loop keyword creates an infinite loop that runs until a break statement is encountered, whereas while true is a conditional loop that checks the boolean true expression before every iteration. Both result in infinite execution, but loop is the idiomatic Rust choice for unbounded repetition because it is more explicit and allows for labeled loops.

fn main() {
    // Idiomatic infinite loop
    loop {
        println!("Running...");
        break; // Must use break to exit
    }

    // Equivalent but less idiomatic
    while true {
        println!("Running...");
        break;
    }
}