pub struct SafeVec<T> { /* private fields */ }Expand description
Safe wrapper around vectors with bounds checking
Implementations§
Source§impl<T> SafeVec<T>
impl<T> SafeVec<T>
Sourcepub fn with_capacity(capacity: usize) -> Self
pub fn with_capacity(capacity: usize) -> Self
Create a safe vector with specified capacity
Sourcepub fn disable_bounds_check(self) -> Self
pub fn disable_bounds_check(self) -> Self
Disable bounds checking for performance (unsafe)
Sourcepub fn get(&self, index: usize) -> UtilsResult<&T>
pub fn get(&self, index: usize) -> UtilsResult<&T>
Safe get with bounds checking
Sourcepub fn get_mut(&mut self, index: usize) -> UtilsResult<&mut T>
pub fn get_mut(&mut self, index: usize) -> UtilsResult<&mut T>
Safe mutable get with bounds checking
Sourcepub fn safe_slice(&self, start: usize, end: usize) -> UtilsResult<&[T]>
pub fn safe_slice(&self, start: usize, end: usize) -> UtilsResult<&[T]>
Safe slice access
Sourcepub unsafe fn as_vec(&self) -> &Vec<T>
pub unsafe fn as_vec(&self) -> &Vec<T>
Access underlying vector (unsafe)
§Safety
This function exposes the underlying Vec<T> directly, bypassing all
bounds checking and overflow protection mechanisms. The caller must
ensure that any modifications to the returned vector do not violate
the buffer’s safety guarantees and internal invariants.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for SafeVec<T>
impl<T> RefUnwindSafe for SafeVec<T>where
T: RefUnwindSafe,
impl<T> Send for SafeVec<T>where
T: Send,
impl<T> Sync for SafeVec<T>where
T: Sync,
impl<T> Unpin for SafeVec<T>where
T: Unpin,
impl<T> UnwindSafe for SafeVec<T>where
T: UnwindSafe,
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more