ループ
Rust には、while、loop、for の 3 つのループ キーワードがあります。
while
while キーワード は、他の言語における while と非常によく似た働きをします。
fn main() {
let mut x = 200;
while x >= 10 {
x = x / 2;
}
println!("Final x: {x}");
}
Press ← or → to navigate between chapters
Press S or / to search in the book
Press ? to show this help
Press Esc to hide this help
Rust には、while、loop、for の 3 つのループ キーワードがあります。
whilewhile キーワード は、他の言語における while と非常によく似た働きをします。
fn main() {
let mut x = 200;
while x >= 10 {
x = x / 2;
}
println!("Final x: {x}");
}