Closed
Description
opened on Mar 5, 2021
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<T>, 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!
Metadata
Assignees
Labels
Area: Constant evaluation, covers all const contexts (static, const fn, ...)Category: An issue tracking the progress of sth. like the implementation of an RFCRelevant to the library API team, which will review and decide on the PR/issue.This issue / PR is in PFCP or FCP with a disposition to merge it.The final comment period is finished for this PR / Issue.
Activity