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
use std::io;use std::process;fnmain(){loop{println!("Please enter the first number: ");let a:u32 = read_user_data();println!("Please enter the second number: ");let b:u32 = read_user_data();let result = sum(a, b);println!("Result: {}", result);}}fnsum(a:u32,b:u32) -> u32{
a + b
}fnread_user_data() -> u32{letmut input = String::new();
io::stdin().read_line(&mut input).unwrap();let number:u32;match input.trim().parse(){Ok(value) => number = value,Err(_error)=> {eprintln!("This is unfortunately not a number");
process::exit(1)}}
number
}
https://github.com/prophen/intro-to-rust/blob/nikema's-notes/exercises/10.md
The text was updated successfully, but these errors were encountered: