ValidationResultExt

Trait ValidationResultExt 

Source
pub trait ValidationResultExt<T> {
    // Required methods
    fn map_valid<U, F>(self, f: F) -> Result<U, ValidationErrors>
       where F: FnOnce(T) -> U;
    fn and_also<U>(
        self,
        other: Result<U, ValidationErrors>,
    ) -> Result<(T, U), ValidationErrors>;
    fn with_errors(
        self,
        other: Result<(), ValidationErrors>,
    ) -> Result<T, ValidationErrors>;
}
Expand description

Extension trait for ValidationResult

Required Methods§

Source

fn map_valid<U, F>(self, f: F) -> Result<U, ValidationErrors>
where F: FnOnce(T) -> U,

Map the success value, preserving validation errors

Source

fn and_also<U>( self, other: Result<U, ValidationErrors>, ) -> Result<(T, U), ValidationErrors>

Combine with another validation result, collecting all errors

Source

fn with_errors( self, other: Result<(), ValidationErrors>, ) -> Result<T, ValidationErrors>

Add errors from another result without changing the success type

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> ValidationResultExt<T> for Result<T, ValidationErrors>

Source§

fn map_valid<U, F>(self, f: F) -> Result<U, ValidationErrors>
where F: FnOnce(T) -> U,

Source§

fn and_also<U>( self, other: Result<U, ValidationErrors>, ) -> Result<(T, U), ValidationErrors>

Source§

fn with_errors( self, other: Result<(), ValidationErrors>, ) -> Result<T, ValidationErrors>

Implementors§