If I have a `Result<T, T>`

it is always possible to get out a `T`

from that. But there is currently no convenient way of doing that.

My current use case is migrating from `Atomic*::compare_and_swap`

to `Atomic*::compare_exchange[_weak]`

. The old return type was just the old value in the atomic. But with `compare_exchange[_weak]`

the return value is `Result<T, T>`

where both the `Ok`

and `Err`

variants contain the old value. For some code I just need to get the old value from this operation. See for example: https://github.com/rust-lang/rust/blob/593fe977a77ad5a7aec23c6cb0f86a3470221670/library/std/src/sync/mpsc/oneshot.rs#L267

I propose adding either a special unwrap method for this:

```
impl<T> Result<T, T> {
pub fn unwrap_either(self) -> T {
match self {
Ok(t) => t,
Err(t) => t,
}
}
}
```

Or doing it via the `From`

trait:

```
impl<T> From<Result<T, T>> for T {...}
```

Since the `Ok(_)`

version of `compare_exchange`

always has a known value (the value of the `current`

argument) it would have been possible to do `.unwrap_err_or(current)`

on my result. But `unwrap_err_or`

does also not exist. And there is also no method for converting `Result<T, E> -> Result<E, T>`

that I can find.

Any way around this problem for my current situation, or would it be a good idea to add some way to easily convert `Result<T, T> -> T`

?