Trait ResultedVec

Source
pub trait ResultedVec<T, E> {
    // Required methods
    fn is_not_empty(self, err: E) -> Result<Vec<T>, E>;
    fn count<U, F: Fn(usize, Vec<T>) -> Result<U, E>>(
        self,
        op: F,
    ) -> Result<U, E>;
    fn into_count(self) -> Result<usize, E>;
    fn into_result(self) -> Result<Vec<T>, E>;
}
Expand description

A trait providing extensions for vectors and results containing vectors, offering additional utility methods.

Required Methods§

Source

fn is_not_empty(self, err: E) -> Result<Vec<T>, E>

Checks if the vector is not empty.

§Parameters
  • err: The error to return if the vector is empty.
§Returns
  • Result<Vec<T>, E>: Ok with the original vector if not empty; otherwise, Err with the provided error.
Source

fn count<U, F: Fn(usize, Vec<T>) -> Result<U, E>>(self, op: F) -> Result<U, E>

Applies a function to the vector, providing the length and the vector itself.

§Parameters
  • op: A closure that takes the length of the vector and the vector, returning a Result.
§Returns
  • Result<U, E>: The result of the closure applied to the length and the vector.
Source

fn into_count(self) -> Result<usize, E>

Converts the vector into its count.

§Returns
  • Result<usize, E>: Ok with the count of elements if the Result is Ok; otherwise, the original Err.
Source

fn into_result(self) -> Result<Vec<T>, E>

Converts the vector into a Result type.

§Returns
  • Result<Vec<T>, E>: Ok with the original vector.

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, E> ResultedVec<T, E> for Result<Vec<T>, E>

Source§

fn is_not_empty(self, err: E) -> Result<Vec<T>, E>

Source§

fn count<U, F: Fn(usize, Vec<T>) -> Result<U, E>>(self, op: F) -> Result<U, E>

Source§

fn into_count(self) -> Result<usize, E>

Source§

fn into_result(self) -> Result<Vec<T>, E>

Source§

impl<T, E> ResultedVec<T, E> for Vec<T>

Source§

fn is_not_empty(self, err: E) -> Result<Vec<T>, E>

Source§

fn count<U, F: Fn(usize, Vec<T>) -> Result<U, E>>(self, op: F) -> Result<U, E>

Source§

fn into_count(self) -> Result<usize, E>

Source§

fn into_result(self) -> Result<Vec<T>, E>

Implementors§