Print errors with Display
instead of Debug
when using ?
in main()
. For example:
use main_error::MainError;
fn main() -> Result<(), MainError> {
// This prints
// "Error: invalid digit found in string"
// instead of (if you used `Result<(), Box<dyn Error>>` or similar)
// "ParseIntError { kind: InvalidDigit }".
let number: i32 = "not a number".parse()?;
Ok(())
}
For more info, see:
- Package information on crates.io
- Documentation on Docs.rs
- Usage examples in the repo