// DOCS NAVIGATION
Estruturas de Controle — Resumo_
SOURCE: content/docs/reference/06-referencia-rapida.md — 06 Referência Rápida / 7. Estruturas de Controle — Resumo / Control Flow Summary
// if / else if / else
if condicao {
// ...
} else if outra {
// ...
} else {
// ...
}
// if not
if not condicao {
// ...
}
// while
while condicao {
// ...
}
// do-while
do {
// ...
} while condicao
// for com range / for with range
for i in 0..10 { /* 0 a 9 */ }
for i in 0..=10 { /* 0 a 10 */ }
// for com array / for with array
for item in arr { /* ... */ }
// loop infinito / infinite loop
loop {
// ...
break
// necessário para sair / needed to exit
}
// switch (comparação por valor / value comparison)
switch valor {
case 1: { println("um")
}
case 2: { println("dois")
}
else: { println("outro")
}
}
// match (pattern matching)
match opcao {
when Option::Some(v) then println(f"Tem: {v}")
otherwise println("Vazio")
}
// if let
if let Option::Some(v) = possivel_valor {
// ...
}
// Control: break / continue
for i in 0..10 {
if i == 3 { continue
}
if i == 7 { break
}
}