mirror of
https://github.com/allankoechke/rust.git
synced 2026-11-30 11:05:36 +00:00
Stabilize `Result::into_{ok,err}`
Tracking issue: https://github.com/rust-lang/rust/issues/61695
---
As evidence of the demand of this API, here are some instances of people having written functions for this functionality:
* 6cc14c4a44/crates/common-utils/src/misc.rs (L7)
* 788e83fa72/src/server/http.rs (L93)
* ea38c0e3b2/nostr/src/util/mod.rs (L120)
* 3d51315599/ngrok/examples/tls.rs (L92)
* b54c112d7d/openraft/openraft/src/error/into_ok.rs (L10)
* 30956f62e6/firmware/src/main.rs (L54)
---
API being stabilized:
```rust
impl<T, E> Result<T, E> {
pub fn into_ok(self) -> T
where
E: Into<!>
{ .... }
pub fn into_err(self) -> E
where
T: Into<!>,
{ .... }
}
```
---
Implementation history: (I'm including only ones that touches the public API being stabilized, and not documentation or constification)
* https://github.com/rust-lang/rfcs/pull/2799
* https://github.com/rust-lang/rust/pull/66045
* https://github.com/rust-lang/rust/pull/83421
* https://github.com/rust-lang/rust/pull/92444