📜  rust 从键盘标准输入输入数字 - Rust 代码示例

📅  最后修改于: 2022-03-11 14:49:25.281000             🧑  作者: Mango

代码示例1
use std::io;

// Request number
println!("Enter number? ");
let mut input = String::new();
io::stdin().read_line(&mut input).expect("Failed to read line");
let bint: i32 = input.trim()
  .parse()
  .ok()
  .expect("Program only processes numbers, Enter number");    
println!("Square {}", bint * bint); // use number