This lesson discusses how to improve error handling by configuring custom error messages using the expect()
function.
use std::io;
fn main() {
let mut first = String::new();
io::stdin().read_line(&mut first);
// Not recommned to use uwnwrap()
let a:u32 = first.trim().parse().unwrap()
// Recommend to use expect() for better error handling
let a:u32 = first.trim().parse().expect("This is a not a valid number")
}
标签:use,errors,let,expect,using,Rust,first From: https://www.cnblogs.com/Answer1215/p/18029454