diff --git a/Examples.md b/Examples.md index b40df33..7727f83 100644 --- a/Examples.md +++ b/Examples.md @@ -717,4 +717,96 @@ fn main println! "{} -> {}", n, big_n ``` - \ No newline at end of file + + +#### loop + + + + + + +
RustHusht
+ +``` +fn main() { + let mut count = 0u32; + println!("Let's count until infinity!"); + loop { + count += 1; + + if count == 3 { + println!("three"); + continue; + } + + println!("{}", count); + + if count == 5 { + println!("OK, that's enough"); + break; + } + } +} +``` + + +``` +fn main + let mut count = 0u32 + println! "Let's count until infinity!" + loop + count += 1 + + if count == 3 + println! "three" + continue + + println! "{}", count + + if count == 5 + println! "OK, that's enough" + break + + + +``` +
+ +##### Nesting and labels + + + + + + +
RustHusht
+ +``` + +``` + + +``` + +``` +
+ +##### Returning from loops + + + + + + +
RustHusht
+ +``` + +``` + + +``` + +``` +