I'm aware of the following methods
let a: u32 = "1".parse().map_err(|_| "Invalid arg")?; let b: u32 = "2".parse().ok().ok_or("Invalid arg")?; let c: u32 = "3".parse().or(Err("Invalid arg"))?;
However, I've noticed the
Option type already has the straightforward
.ok_or(literal), is there a reason why
Result doesn't implement this method? And what would be another direct approach than the ones mentioned above?