We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
NonNull::new
const
1 parent 16c1a9d commit 5e97fc9Copy full SHA for 5e97fc9
library/core/src/ptr/non_null.rs
@@ -211,8 +211,9 @@ impl<T: ?Sized> NonNull<T> {
211
/// }
212
/// ```
213
#[stable(feature = "nonnull", since = "1.25.0")]
214
+ #[rustc_const_unstable(feature = "const_nonnull_new", issue = "93235")]
215
#[inline]
- pub fn new(ptr: *mut T) -> Option<Self> {
216
+ pub const fn new(ptr: *mut T) -> Option<Self> {
217
if !ptr.is_null() {
218
// SAFETY: The pointer is already checked and is not null
219
Some(unsafe { Self::new_unchecked(ptr) })
0 commit comments