From eaa00d4081afebb92659cabc734136b5dfd5c61c Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Sun, 25 Aug 2024 03:56:26 +0000 Subject: [PATCH] Update Examples --- Examples.md | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 93 insertions(+), 1 deletion(-) 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
+ +``` + +``` + + +``` + +``` +