pub struct AtomicRefArray<T> { /* private fields */ }
Expand description
An array of non-optional references in which elements may be updated and retrieved atomically.
Implementations§
Source§impl<T> AtomicRefArray<T>
impl<T> AtomicRefArray<T>
Sourcepub fn new(len: usize) -> Selfwhere
T: Default,
pub fn new(len: usize) -> Selfwhere
T: Default,
Constructs a new array with the specified length. All values will be initialized to their default.
Sourcepub fn new_with<U: Into<Arc<T>>>(len: usize, f: impl Fn(usize) -> U) -> Self
pub fn new_with<U: Into<Arc<T>>>(len: usize, f: impl Fn(usize) -> U) -> Self
Constructs a new array with the specified length. Uses the given function to construct each value.
Sourcepub fn load(&self, index: usize) -> Arc<T>
pub fn load(&self, index: usize) -> Arc<T>
Loads and returns a reference to an value at the given position or None
if the value at the index is not set.
Panics if index
is out of bounds.
Auto Trait Implementations§
impl<T> Freeze for AtomicRefArray<T>
impl<T> RefUnwindSafe for AtomicRefArray<T>
impl<T> Send for AtomicRefArray<T>
impl<T> Sync for AtomicRefArray<T>
impl<T> Unpin for AtomicRefArray<T>
impl<T> UnwindSafe for AtomicRefArray<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