Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions library/core/src/sync/atomic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1550,6 +1550,24 @@ impl<T> AtomicPtr<T> {
unsafe { &*ptr.cast() }
}

/// Creates a new `AtomicPtr` initialized with a null pointer.
///
/// # Examples
///
/// ```
/// #![feature(atomic_ptr_null)]
/// use std::sync::atomic::{AtomicPtr, Ordering};
///
/// let atomic_ptr = AtomicPtr::<()>::null();
/// assert!(atomic_ptr.load(Ordering::Relaxed).is_null());
/// ```
#[inline]
#[must_use]
#[unstable(feature = "atomic_ptr_null", issue = "150733")]
pub const fn null() -> AtomicPtr<T> {
AtomicPtr::new(crate::ptr::null_mut())
}

/// Returns a mutable reference to the underlying pointer.
///
/// This is safe because the mutable reference guarantees that no other threads are
Expand Down
Loading