Closed
Description
The only way to introspect reason of .parse
failure is to compare to error messages returned by description or use the following code snippet:
let overflow = "1231123123123123".parse::<u32>().err().unwrap();
let underflow = "-1231123123123123".parse::<i32>().err().unwrap();
match "999999999999".parse::<u32>() {
Ok(n) => println!("{}", n),
Err(ref e) if *e == overflow => println!("Overflow"),
Err(ref e) if *e == underflow => println!("Underflow"),
_ => panic!("wow, no introspection, very convenience")
}
Metadata
Metadata
Assignees
Labels
Area: Floating point numbers and arithmeticBlocker: Implemented in the nightly compiler and unstable.Category: An issue tracking the progress of sth. like the implementation of an RFCLibs issues that are tracked on the team's project board.Relevant to the library API team, which will review and decide on the PR/issue.