Tracking Issue for const Result
methods · Issue #82814 · rust-lang/rust (original) (raw)
Feature gate: #![feature(const_result)]
This is a tracking issue for making a number of Result
methods const fn
.
Public API
NB: Many of these methods will need ~const Drop
. They're omitted here for brevity.
impl<T, E> Result<T, E> { pub const fn as_mut(&mut self) -> Result<&mut T, &mut E>; }
impl<T, E> Result<Option, E> { pub const fn transpose(self) -> Option<Result<T, E>>; }
impl<T, E> Result<&T, E> { pub const fn copied(self) -> Result<T, E> where T: Copy; }
impl<T, E> Result<&mut T, E> { pub const fn copied(self) -> Result<T, E> where T: Copy; }
Note some things are missing compared with Option
(#67441):
unwrap
,expect
: drops the error, so cannot be done in const.flatten
: is not stable yet onResult
, even outside const.take
,replace
: does not exist onResult
.
See also #57563.
Please post a comment in this issue if you're submitting a PR that changes any of the above!