I have functions that return an Option or a Result:
fn get_my_result() -> Result<(), Box<Error>> {
lots_of_things()?;
Ok(()) // Could this be omitted?
}
fn get_my_option() -> Option<&'static str> {
if some_condition {
return Some("x");
}
if another_condition {
return Some("y");
}
None // Could this be omitted as well?
}
Currently, neither Ok(()) or None are allowed to be omitted, as shown in the examples above. Is there a reason for that? Is it possible for this to be changed in the future?
Update
We can use Fehler to write code like this:
#[throws(Box<Error>)]
fn get_my_result() {
let value = lots_of_things()?;
// No need to return Ok(())
}
Fehler also allows to throw as Option.