I think this would be a great ergonomics win for functions that take optional parameters. Eg, for a function:
fn myfn(a: Option<u8>, b: Option<u8>, c: Option<u8>) -> u8;
Right now you must call it as
myfn(Some(0), None, Some(2))
or similar. With
impl From<T> for Option<T>, you’d be able to call it as
myfn(0, None, 2)
which removes a lot of noise at the call site. The definition of
myfn would gain some noise:
fn myfn(t: T, u: U, v: V) -> Option where T: Into<Option<u8>>, U: Into<Option<u8>>, V: Into<Option<u8>>;
However, I think that pushing the noise into the definition makes for nicer user code overall.
I feel like this is an obvious impl, and so there must be a good reason it’s not already in
std. Am I missing something? Should I just make a PR from this commit?