Struct zarrs::array::UnsafeCellSlice
source · pub struct UnsafeCellSlice<'a, T>(/* private fields */);
Expand description
An unsafe cell slice.
It can be used to acquire multiple mutable references to a slice enabling writing from multiple threads. This is inherently unsafe and it is the responsibility of the caller to ensure safety.
Implementations§
source§impl<'a, T: Copy> UnsafeCellSlice<'a, T>
impl<'a, T: Copy> UnsafeCellSlice<'a, T>
sourcepub fn new(slice: &'a mut [T]) -> Self
pub fn new(slice: &'a mut [T]) -> Self
Create a new UnsafeCellSlice
.
sourcepub fn new_from_vec_with_spare_capacity(vec: &'a mut Vec<T>) -> Self
pub fn new_from_vec_with_spare_capacity(vec: &'a mut Vec<T>) -> Self
Create a new UnsafeCellSlice
from the spare capacity in a Vec
.
sourcepub unsafe fn get(&self) -> &mut [T]
pub unsafe fn get(&self) -> &mut [T]
Get a mutable reference to the underlying slice.
§Safety
This returns a mutable reference to the underlying slice despite self
being a non-mutable reference.
This is unsafe because it can be called multiple times, thus creating multiple mutable references to the same data.
It is the responsibility of the caller not to write to the same slice element from than one thread.
Trait Implementations§
source§impl<'a, T: Clone> Clone for UnsafeCellSlice<'a, T>
impl<'a, T: Clone> Clone for UnsafeCellSlice<'a, T>
source§fn clone(&self) -> UnsafeCellSlice<'a, T>
fn clone(&self) -> UnsafeCellSlice<'a, T>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreimpl<'a, T: Copy> Copy for UnsafeCellSlice<'a, T>
impl<'a, T: Send + Sync> Send for UnsafeCellSlice<'a, T>
impl<'a, T: Send + Sync> Sync for UnsafeCellSlice<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for UnsafeCellSlice<'a, T>
impl<'a, T> !RefUnwindSafe for UnsafeCellSlice<'a, T>
impl<'a, T> Unpin for UnsafeCellSlice<'a, T>
impl<'a, T> !UnwindSafe for UnsafeCellSlice<'a, T>
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