Increase code-reuse and -readability

This commit is contained in:
Oliver Scherer 2018-11-19 14:45:40 +01:00
parent 37ef5e43af
commit 3ce211dbd0

View file

@ -2903,7 +2903,7 @@ impl<T: ?Sized> NonNull<T> {
#[inline]
pub fn new(ptr: *mut T) -> Option<Self> {
if !ptr.is_null() {
Some(NonNull { pointer: unsafe { NonZero(ptr as _) } })
Some(unsafe { Self::new_unchecked(ptr) })
} else {
None
}