Skip to content

Commit

Permalink
Make NonNull::dangling a const fn
Browse files Browse the repository at this point in the history
  • Loading branch information
Amanieu committed Sep 29, 2018
1 parent 6846f22 commit fcc7671
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/libcore/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2874,10 +2874,9 @@ impl<T: Sized> NonNull<T> {
/// sentinel value. Types that lazily allocate must track initialization by
/// some other means.
#[stable(feature = "nonnull", since = "1.25.0")]
pub fn dangling() -> Self {
pub const fn dangling() -> Self {
unsafe {
let ptr = mem::align_of::<T>() as *mut T;
NonNull::new_unchecked(ptr)
NonNull::new_unchecked(mem::align_of::<T>() as *mut T)
}
}
}
Expand Down

0 comments on commit fcc7671

Please sign in to comment.