You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fnmain(){let args :Vec<String> = std::env::args().collect();if args.len() > 1{println!("First argument: {}", args[1]);}else{println!("There is no argument!");}}
fnmain(){let args :Vec<String> = std::env::args().collect();let s = if args.len() > 1{
args[1].clone()}else{"no argument".to_string()};println!("First argument: {}", s);}
if let statements
fnmain(){let args :Vec<String> = std::env::args().collect();for a in&args[1..]{let x = i64::from_str_radix(a,10);ifletOk(y) = x {println!("Found number {}", y);}else{println!("No number: {}", a);}}}
Loops
fnmain(){letmut i = 0;'out:loop{letmut j = 0;loop{if(i *3 + j *5) % 15 == 4{println!("4 = {} * 3 + {} * 5 mod 15", i, j);break'out;}
j += 1;if j == 3{break;}}
i += 1;}}
while loops
fnmain(){letmut i = 0;'out:while i < 5{letmut j = 0;while j < 3{if(i *3 + j *5) % 15 == 4{println!("4 = {} * 3 + {} * 5 mod 15", i, j);break'out;}
j += 1;}
i += 1;}}
for loops
fnmain(){'out:for i in0..5{for j in0..=2{if(i *3 + j *5) % 15 == 4{println!("4 = {} * 3 + {} * 5 mod 15", i, j);break'out;}}}}
fnmain(){let args :Vec<String> = std::env::args().collect();'out:for a in&args {println!("New argument.");for c in a.chars(){println!("Char: {}", c);if c == 'x'{break'out;}elseif c == 'y'{continue'out;}}}}