Skip to content

Commit 5e97fc9

Browse files
committed
Make NonNull::new const
1 parent 16c1a9d commit 5e97fc9

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

library/core/src/ptr/non_null.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,9 @@ impl<T: ?Sized> NonNull<T> {
211211
/// }
212212
/// ```
213213
#[stable(feature = "nonnull", since = "1.25.0")]
214+
#[rustc_const_unstable(feature = "const_nonnull_new", issue = "93235")]
214215
#[inline]
215-
pub fn new(ptr: *mut T) -> Option<Self> {
216+
pub const fn new(ptr: *mut T) -> Option<Self> {
216217
if !ptr.is_null() {
217218
// SAFETY: The pointer is already checked and is not null
218219
Some(unsafe { Self::new_unchecked(ptr) })

0 commit comments

Comments
 (0)