Trait optics::traits::OpticsFallible

source ·
pub trait OpticsFallible {
    type Success;
    type Error;

    // Required method
    fn success_witness(&self) -> Self::Success;

    // Provided methods
    fn map_fallible<S, F, E, G>(self, f: F, g: G) -> MapFallible<Self, F, G>
       where Self: Sized,
             F: Fn(Self::Success) -> S,
             G: Fn(Self::Error) -> E { ... }
    fn map_success<S, F>(self, f: F) -> MapSuccess<Self, F>
       where Self: Sized,
             F: Fn(Self::Success) -> S { ... }
    fn map_error<E, G>(self, g: G) -> MapError<Self, G>
       where Self: Sized,
             G: Fn(Self::Error) -> E { ... }
    fn assert_infallible(self) -> MapFallibleTo<Self, Self::Success, Infallible>
       where Self: Sized,
             Self::Error: Debug { ... }
    fn to_str_err(self) -> MapFallibleTo<Self, Self::Success, String>
       where Self: Sized,
             Self::Error: Display { ... }
}
Expand description

Optics with a success type and an error type associated.

Required Associated Types§

source

type Success

Success type for this optics.

source

type Error

Error type for this optics.

Required Methods§

source

fn success_witness(&self) -> Self::Success

Get a lightweight witness for success.

Provided Methods§

source

fn map_fallible<S, F, E, G>(self, f: F, g: G) -> MapFallible<Self, F, G>
where Self: Sized, F: Fn(Self::Success) -> S, G: Fn(Self::Error) -> E,

Map the Success and Error type for this fallible optics.

source

fn map_success<S, F>(self, f: F) -> MapSuccess<Self, F>
where Self: Sized, F: Fn(Self::Success) -> S,

Map the Success type for this fallible optics.

source

fn map_error<E, G>(self, g: G) -> MapError<Self, G>
where Self: Sized, G: Fn(Self::Error) -> E,

Map the Error type for this fallible optics.

source

fn assert_infallible(self) -> MapFallibleTo<Self, Self::Success, Infallible>
where Self: Sized, Self::Error: Debug,

Assert that this optics should never fail (in practice). The resulting optics panics on error.

source

fn to_str_err(self) -> MapFallibleTo<Self, Self::Success, String>
where Self: Sized, Self::Error: Display,

Map the Error type to Box<str>.

Implementations on Foreign Types§

source§

impl<L: OpticsFallible> OpticsFallible for &L

Implementors§