Skip to main content

SliceExt

Trait SliceExt 

Source
pub trait SliceExt<T> {
    // Required methods
    fn get_or_cbkp_error(
        &self,
        index: usize,
        code: ErrorCode,
        message: impl Into<String>,
    ) -> Result<&T>;
    fn get_mut_or_cbkp_error(
        &mut self,
        index: usize,
        code: ErrorCode,
        message: impl Into<String>,
    ) -> Result<&mut T>;
}
Expand description

Extension trait for slice indexing providing panic-safe access

Required Methods§

Source

fn get_or_cbkp_error( &self, index: usize, code: ErrorCode, message: impl Into<String>, ) -> Result<&T>

Get element at index safely, returning a structured error if out of bounds

§Errors

Returns the specified error code and message if the index is out of bounds.

Source

fn get_mut_or_cbkp_error( &mut self, index: usize, code: ErrorCode, message: impl Into<String>, ) -> Result<&mut T>

Get mutable element at index safely, returning a structured error if out of bounds

§Errors

Returns the specified error code and message if the index is out of bounds.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T> SliceExt<T> for [T]

Source§

fn get_or_cbkp_error( &self, index: usize, code: ErrorCode, message: impl Into<String>, ) -> Result<&T>

Source§

fn get_mut_or_cbkp_error( &mut self, index: usize, code: ErrorCode, message: impl Into<String>, ) -> Result<&mut T>

Implementors§