pub(crate) struct OnceBox<T> {
ptr: Atomic<*mut T>,
}
Fields§
§ptr: Atomic<*mut T>
Implementations§
Source§impl<T> OnceBox<T>
impl<T> OnceBox<T>
pub const fn new() -> Self
Sourcepub unsafe fn get_unchecked(&self) -> Pin<&T>
pub unsafe fn get_unchecked(&self) -> Pin<&T>
Gets access to the value, assuming it is already initialized and this initialization has been observed by the current thread.
Since all modifications to the pointer have already been observed, the pointer load in this function can be performed with relaxed ordering, potentially allowing the optimizer to turn code like this:
into
§Safety
This causes undefined behavior if the assumption above is violated.
pub fn get_or_init(&self, f: impl FnOnce() -> Pin<Box<T>>) -> Pin<&T>
pub fn take(&mut self) -> Option<Pin<Box<T>>>
fn initialize(&self, f: impl FnOnce() -> Pin<Box<T>>) -> Pin<&T>
Trait Implementations§
impl<T: Send> Send for OnceBox<T>
impl<T: Send + Sync> Sync for OnceBox<T>
Auto Trait Implementations§
impl<T> !Freeze for OnceBox<T>
impl<T> RefUnwindSafe for OnceBox<T>
impl<T> Unpin for OnceBox<T>
impl<T> UnwindSafe for OnceBox<T>where
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> SizedTypeProperties for T
impl<T> SizedTypeProperties for T
Source§#[doc(hidden)] const IS_ZST: bool = _
#[doc(hidden)] const IS_ZST: bool = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)Source§#[doc(hidden)] const LAYOUT: Layout = _
#[doc(hidden)] const LAYOUT: Layout = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)Source§#[doc(hidden)] const MAX_SLICE_LEN: usize = _
#[doc(hidden)] const MAX_SLICE_LEN: usize = _
🔬This is a nightly-only experimental API. (
sized_type_properties
)The largest safe length for a
[Self]
. Read more