Skip to main content

VecExt

Trait VecExt 

Source
pub trait VecExt<T> {
    // Required methods
    fn pop_or_cbkp_error(
        &mut self,
        code: ErrorCode,
        message: impl Into<String>,
    ) -> Result<T, Error>;
    fn last_or_cbkp_error(
        &self,
        code: ErrorCode,
        message: impl Into<String>,
    ) -> Result<&T, Error>;
    fn last_mut_or_cbkp_error(
        &mut self,
        code: ErrorCode,
        message: impl Into<String>,
    ) -> Result<&mut T, Error>;
}
Expand description

Extension trait for Vec<T> providing panic-safe access operations

Required Methods§

Source

fn pop_or_cbkp_error( &mut self, code: ErrorCode, message: impl Into<String>, ) -> Result<T, Error>

Pop from vector safely, returning a structured error if empty

§Errors

Returns the specified error code and message if the vector is empty.

Source

fn last_or_cbkp_error( &self, code: ErrorCode, message: impl Into<String>, ) -> Result<&T, Error>

Get last element safely, returning a structured error if empty

§Errors

Returns the specified error code and message if the vector is empty.

Source

fn last_mut_or_cbkp_error( &mut self, code: ErrorCode, message: impl Into<String>, ) -> Result<&mut T, Error>

Get last mutable element safely, returning a structured error if empty

§Errors

Returns the specified error code and message if the vector is empty.

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> VecExt<T> for Vec<T>

Source§

fn pop_or_cbkp_error( &mut self, code: ErrorCode, message: impl Into<String>, ) -> Result<T, Error>

Source§

fn last_or_cbkp_error( &self, code: ErrorCode, message: impl Into<String>, ) -> Result<&T, Error>

Source§

fn last_mut_or_cbkp_error( &mut self, code: ErrorCode, message: impl Into<String>, ) -> Result<&mut T, Error>

Implementors§