-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Tracking Issue for option_result_unwrap_unchecked #81383
Copy link
Copy link
Closed
Labels
A-result-optionArea: Result and Option combinatorsArea: Result and Option combinatorsC-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.
Metadata
Metadata
Assignees
Labels
A-result-optionArea: Result and Option combinatorsArea: Result and Option combinatorsC-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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Feature gate:
#![feature(option_result_unwrap_unchecked)]This is a tracking issue for the unchecked variants of
unwrap()andunwrap_err()ofOptionandResult.These are unsafe functions intended to be used in hot paths of performance sensitive applications where the variant an
Option/Resultholds is known, allowing to skip the branch that the safe version introduces. They complement other*_unchecked()methods already available, such asget_unchecked()in slices.Public API
Steps / History
unwrap_unchecked()methods forOptionandResult#80876option_result_unwrap_unchecked#81383 (comment)option_result_unwrap_unchecked#81383 (comment)option_result_unwrap_unchecked#89951Unresolved Questions
Should we add
expect_unchecked, and if yes, do it within another feature flag, to unblockunwrap_unchecked? Tracking Issue foroption_result_unwrap_unchecked#81383 (comment)Should we panic on failure in debug (i.e. for those projects that build
corethemselves)? If yes, that would mean there is no way to actually remove the check for those projects, which could be potentially needed by someone. If we do, should it be documented? Tracking Issue foroption_result_unwrap_unchecked#81383 (comment)debug_assert!, which may be useful for projects that buildcorewith debug assertions enabled (e.g. the bors test suite or some embedded projects), but this is not documented, and indeed most users will not see such behavior, sincecoreis shipped in release mode.Should we name them
unchecked_unwrapinstead? Tracking Issue foroption_result_unwrap_unchecked#81383 (comment).unwrap_unchecked) follows the convention of other stable methods in the standard library such asget_unchecked,map_unchecked,new_unchecked,unreachable_unchecked... (see as well https://rust-lang.github.io/api-guidelines/naming.html#getter-names-follow-rust-convention-c-getter).unchecked_{add,...}methods seem to follow the opposite convention, but those are unstable and they likely do it because the stable{checked,...}_{add,...}exist.