3 ms·
Rust is an expression-based language, so a loop block is just an expression. Break exits the loop and returns the expression following the keyword, which is the
by at_compile_time 4y ago
Rust is an expression-based language, so a loop block is just an expression. Break exits the loop and returns the expression following the keyword, which is the integer 1 in this example, but it could also be nothing if the loop returns nothing (aka unit "()", aka void in some languages), or any other expression as well.