Add a Result::into_ok_or_err
method to extract a T
from Result<T, T>
by thomcc · Pull Request #80572 · rust-lang/rust (original) (raw)
I'm comfortable renaming if desired. I think ok_or_err
is clearer than into_inner
, but into_inner
is pretty good too (better than most of the other suggestions I got, which were: merge
, collapse
, converge
, either_value
, unwrap_either
, ...).
I don't care that much about the name so long as the functionality is available under some name though.
Another suggestion I got was implementing From<Result<T, T>> for (bool, T)
, which is probably possible, but I didn't like, mainly because that seems strictly less convenient. For example, in the cas=>cmpxchg transition, I'd need to make atom.compare_and_swap(a, b, <ordering>)
into <(bool, T)>::from(atom.compare_exchange(a, b, <ordering0>, <ordering1>)).1
, which is awkward.