That’s right, but that’s also not subject of the discussion. My thesis is that return type of () turns a returning expression into imperative statement, since () represents void. And even if void is a value, it’s hard to say that it’s a result, since it’s useless.
It would know a concrete type I want.
Consider the following code:
option or Err(0);
It would be desugared:
match Or::into_option(option) {
Some(o) => From::from(o),
None => Err(0),
}
And then inlined:
match option {
Some(o) => Ok(o),
None => Err(0)
}
Or did you wanted to say that this couldn’t happen?
That’s good point. I think that some trait bound on Or type parameter would be required to deny values that allocates in from function. Or we can use another trait instead.
That requires further investigation…
Sometimes you need a more straightforward way to handle nullable values: option or value, option or next_option, option or result…
Handling nullable values in if and match expressions is less straightforward than could be with or.
Handling nullable with Option<T> combinators is less straightforward than with if and match.
Handling null as error using ? and try blocks is not straightforward at all.