-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.
Description
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!
drcatdoctor and greyblakefmease, oilaba, lemmih, arialpew, biro456 and 4 more
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.Relevant to the library API team, which will review and decide on the PR/issue.disposition-mergeThis issue / PR is in PFCP or FCP with a disposition to merge it.This issue / PR is in PFCP or FCP with a disposition to merge it.finished-final-comment-periodThe final comment period is finished for this PR / Issue.The final comment period is finished for this PR / Issue.