mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-04 04:39:16 +00:00
Rename {NonZero,Shared,Unique}::new_checked to new
This commit is contained in:
parent
0a08ad0443
commit
ddaf9b24f0
@ -75,7 +75,7 @@ impl<T: Zeroable> NonZero<T> {
|
||||
|
||||
/// Creates an instance of NonZero with the provided value.
|
||||
#[inline]
|
||||
pub fn new_checked(inner: T) -> Option<Self> {
|
||||
pub fn new(inner: T) -> Option<Self> {
|
||||
if inner.is_zero() {
|
||||
None
|
||||
} else {
|
||||
|
@ -1115,8 +1115,8 @@ impl<T: ?Sized> Unique<T> {
|
||||
}
|
||||
|
||||
/// Creates a new `Unique` if `ptr` is non-null.
|
||||
pub fn new_checked(ptr: *mut T) -> Option<Self> {
|
||||
NonZero::new_checked(ptr as *const T).map(|nz| Unique { pointer: nz, _marker: PhantomData })
|
||||
pub fn new(ptr: *mut T) -> Option<Self> {
|
||||
NonZero::new(ptr as *const T).map(|nz| Unique { pointer: nz, _marker: PhantomData })
|
||||
}
|
||||
|
||||
/// Acquires the underlying `*mut` pointer.
|
||||
@ -1234,8 +1234,8 @@ impl<T: ?Sized> Shared<T> {
|
||||
}
|
||||
|
||||
/// Creates a new `Shared` if `ptr` is non-null.
|
||||
pub fn new_checked(ptr: *mut T) -> Option<Self> {
|
||||
NonZero::new_checked(ptr as *const T).map(|nz| Shared { pointer: nz, _marker: PhantomData })
|
||||
pub fn new(ptr: *mut T) -> Option<Self> {
|
||||
NonZero::new(ptr as *const T).map(|nz| Shared { pointer: nz, _marker: PhantomData })
|
||||
}
|
||||
|
||||
/// Acquires the underlying `*mut` pointer.
|
||||
|
Loading…
Reference in New Issue
Block a user