mirror of
https://bitbucket.org/Mattrixwv/rusttutorials.git
synced 2025-12-07 11:03:58 -05:00
Added chapter 8
This commit is contained in:
22
src/FlowOfControl/Loop/NestingAndLabels.rs
Normal file
22
src/FlowOfControl/Loop/NestingAndLabels.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
#[allow(unreachable_code)]
|
||||
#[allow(unused_labels)]
|
||||
|
||||
|
||||
pub fn main(){
|
||||
'outer: loop{
|
||||
println!("Entered the outer loop");
|
||||
|
||||
'inner: loop{
|
||||
println!("Entered the inner loop");
|
||||
|
||||
//This would break only the inner loop break;
|
||||
|
||||
//This breaks the outer loop
|
||||
break 'outer;
|
||||
}
|
||||
|
||||
println!("This point will never be reached");
|
||||
}
|
||||
|
||||
println!("Exited the outer loop");
|
||||
}
|
||||
Reference in New Issue
Block a user