Skip to content

Commit b23fd43

Browse files
committed
Make Unique::as_ptr, NonNull::dangling and NonNull::cast const
1 parent fb162e6 commit b23fd43

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libcore/ptr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2790,7 +2790,7 @@ impl<T: ?Sized> Unique<T> {
27902790
}
27912791

27922792
/// Acquires the underlying `*mut` pointer.
2793-
pub fn as_ptr(self) -> *mut T {
2793+
pub const fn as_ptr(self) -> *mut T {
27942794
self.pointer as *mut T
27952795
}
27962796

@@ -2903,7 +2903,7 @@ impl<T: Sized> NonNull<T> {
29032903
/// some other means.
29042904
#[stable(feature = "nonnull", since = "1.25.0")]
29052905
#[inline]
2906-
pub fn dangling() -> Self {
2906+
pub const fn dangling() -> Self {
29072907
unsafe {
29082908
let ptr = mem::align_of::<T>() as *mut T;
29092909
NonNull::new_unchecked(ptr)
@@ -2966,7 +2966,7 @@ impl<T: ?Sized> NonNull<T> {
29662966
/// Cast to a pointer of another type
29672967
#[stable(feature = "nonnull_cast", since = "1.27.0")]
29682968
#[inline]
2969-
pub fn cast<U>(self) -> NonNull<U> {
2969+
pub const fn cast<U>(self) -> NonNull<U> {
29702970
unsafe {
29712971
NonNull::new_unchecked(self.as_ptr() as *mut U)
29722972
}

0 commit comments

Comments
 (0)