In this lesson we'll explore how to unwrap a Result
type using a language feature called Pattern Matching.
use std::io;
fn main() {
let mut first = String::new();
io::stdin().read_line(&mut first).unwrap();
let mut a:u32 = 0;
match first.trim().parse() {
Ok(val) => {
a = val;
},
Err(err) => {
println!("This is not a valid number")
}
}
}
标签:mut,errors,Handle,Pattern,using,Matching,Rust,first From: https://www.cnblogs.com/Answer1215/p/18029463