diff options
| author | woppopo <woppopo@protonmail.com> | 2022-01-23 23:04:39 +0900 |
|---|---|---|
| committer | woppopo <woppopo@protonmail.com> | 2022-01-23 23:04:39 +0900 |
| commit | 5e97fc9aa265cb523a16cbe035c638eb35257cf5 (patch) | |
| tree | fd388791ac7f8136f42e8870c9f195c987ddc385 | |
| parent | 16c1a9dd7cd497b050bc957cdfa54f8d3d6e97f2 (diff) | |
| download | rust-5e97fc9aa265cb523a16cbe035c638eb35257cf5.tar.gz rust-5e97fc9aa265cb523a16cbe035c638eb35257cf5.zip | |
Make `NonNull::new` `const`
| -rw-r--r-- | library/core/src/ptr/non_null.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/library/core/src/ptr/non_null.rs b/library/core/src/ptr/non_null.rs index 3a7e99faccf..3f5d3f62c96 100644 --- a/library/core/src/ptr/non_null.rs +++ b/library/core/src/ptr/non_null.rs @@ -211,8 +211,9 @@ impl<T: ?Sized> NonNull<T> { /// } /// ``` #[stable(feature = "nonnull", since = "1.25.0")] + #[rustc_const_unstable(feature = "const_nonnull_new", issue = "93235")] #[inline] - pub fn new(ptr: *mut T) -> Option<Self> { + pub const fn new(ptr: *mut T) -> Option<Self> { if !ptr.is_null() { // SAFETY: The pointer is already checked and is not null Some(unsafe { Self::new_unchecked(ptr) }) |
