pub struct SliceCell<'a, T> { /* private fields */ }Expand description
Slice with dynamic borrow checking.
Implementations§
Source§impl<'a, T> SliceCell<'a, T>
impl<'a, T> SliceCell<'a, T>
Sourcepub fn new(data: &'a mut [T]) -> Self
pub fn new(data: &'a mut [T]) -> Self
Returns the same exclusive slice but with dynamic borrow checking.
Sourcepub fn get(&self, index: usize) -> Result<&T, Error>
pub fn get(&self, index: usize) -> Result<&T, Error>
Returns a shared reference to an element of the underlying slice.
Sourcepub fn get_mut(&self, index: usize) -> Result<&mut T, Error>
pub fn get_mut(&self, index: usize) -> Result<&mut T, Error>
Returns an exclusive reference to an element of the underlying slice.
Sourcepub fn get_range(&self, range: impl RangeBounds<usize>) -> Result<&[T], Error>
pub fn get_range(&self, range: impl RangeBounds<usize>) -> Result<&[T], Error>
Returns a shared slice reference of the underlying slice.
Sourcepub fn get_range_mut(
&self,
range: impl RangeBounds<usize>,
) -> Result<&mut [T], Error>
pub fn get_range_mut( &self, range: impl RangeBounds<usize>, ) -> Result<&mut [T], Error>
Returns an exclusive slice reference of the underlying slice.
Auto Trait Implementations§
impl<'a, T> !Freeze for SliceCell<'a, T>
impl<'a, T> !RefUnwindSafe for SliceCell<'a, T>
impl<'a, T> !Send for SliceCell<'a, T>
impl<'a, T> !Sync for SliceCell<'a, T>
impl<'a, T> Unpin for SliceCell<'a, T>
impl<'a, T> UnsafeUnpin for SliceCell<'a, T>
impl<'a, T> UnwindSafe for SliceCell<'a, 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