-
Notifications
You must be signed in to change notification settings - Fork 14k
Closed
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-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.
Description
Now that NonNull has been added and Option<NonNull<T>> is preferred over *mut T, if you have code that used to know that a *mut T was non-null and dereferenced it, you now know that your Option<NonNull<T>> is Some and can call .unwrap() on it. However, .unwrap() can incur runtime overhead that dereferencing *mut T never would. Since a lot of performance-critical code is written using raw pointers (and now, NonNull), this runtime overhead may be worth worrying about.
I propose, for these cases, to introduce an unsafe unwrap_unchecked method to Option that returns a T by simply assuming that the Option is currently Some(T).
Lokathor, andreytkachenko, delacian, anyputer, Anders429 and 2 more
Metadata
Metadata
Assignees
Labels
C-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-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.