Advertisement
dimkiriaoks

Rust

Mar 10th, 2024
1,462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.41 KB | None | 0 0
  1. fn main(){
  2.     let mut x_string: String = String::new();
  3.     let mut y_string: String = String::new();
  4.  
  5.     println!("X?");
  6.     let _ = std::io::stdin().read_line(&mut x_string);
  7.    
  8.     println!("Y?");
  9.     let _ = std::io::stdin().read_line(&mut y_string);
  10.  
  11.     let x: Result<i32, _> = x_string.parse();
  12.     let y: Result<i32, _> = y_string.parse();
  13.    
  14.     let mut z = x+y;
  15.     println!("Z: {z}");
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement