Closed
Description
Someone want to remove one of .foo()
and .foo_opt()
, but that will let us write more foo().unwrap()
, which is a bit nasty. I'd like to see introducing a new syntax sugar: foo()!
, which means the same as foo().unwrap()
. The !
here means: 1) ensure it's not None, 2) it maybe fail!.
We can define a trait Unwrapable<T>
that has an fn unwrap() -> T
, and impl it for Option, Result<T,E> and others. When !
operated on an Unwrapable value, rustc call its unwrap()
automatically. (I do not know whether or not it will be ambiguous with macro!.)
After it is accepted, we may safely remove one of .foo() and .foo_opt().
Metadata
Metadata
Assignees
Labels
No labels