[][src]Function tao_of_rust::ch02::control_flow::loop_fizzbuzz

pub fn loop_fizzbuzz()

while表达式

Basic usage:

fn loop_fizzbuzz() {
    let mut n = 1;
    loop {
        if n > 101 { break; }
        if n % 15 == 0 {
            println!("fizzbuzz");
        } else if n % 3 == 0 {
            println!("fizz");
        } else if n % 5 == 0 {
            println!("buzz");
        } else {
            println!("{}", n);
        }
        n += 1;
    }
}
loop_fizzbuzz();Run