let num = Some(22);
if num.is_some() {
println!("number is: {}", num.unwrap());
}
// match pattern and assign variable
if let Some(i) = num {
println!("number is: {}", i);
}
let mut count = 0;
loop {
count += 1;
if count == 5 {
break; // Exit loop
}
}
'outer: loop {
'inner: loop {
break; // This breaks the inner loop
break 'outer; // This breaks the outer loop
}
}
let mut counter = 0;
let result = loop {
counter += 1;
if counter == 10 {
break counter;
}
};
while n < 101 {
n += 1;
}
let mut optional = Some(0);
while let Some(i) = optional {
print!("{}", i);
}
for n in 1..101 {
println!("{}", n);
}
let names = vec!["Bogdan", "Wallace"];
for name in names.iter() {
println!("{}", name);
}
let optional = Some(0);
match optional {
Some(i) => println!("{}", i),
None => println!("No value.")
}