Closed
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)
.