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§
Required Methods§
sourcefn success_witness(&self) -> Self::Success
fn success_witness(&self) -> Self::Success
Get a lightweight witness for success.
Provided Methods§
sourcefn map_fallible<S, F, E, G>(self, f: F, g: G) -> MapFallible<Self, F, G>
fn map_fallible<S, F, E, G>(self, f: F, g: G) -> MapFallible<Self, F, G>
Map the Success
and Error
type for this fallible optics.
sourcefn map_success<S, F>(self, f: F) -> MapSuccess<Self, F>
fn map_success<S, F>(self, f: F) -> MapSuccess<Self, F>
Map the Success
type for this fallible optics.
sourcefn map_error<E, G>(self, g: G) -> MapError<Self, G>
fn map_error<E, G>(self, g: G) -> MapError<Self, G>
Map the Error
type for this fallible optics.
sourcefn assert_infallible(self) -> MapFallibleTo<Self, Self::Success, Infallible>
fn assert_infallible(self) -> MapFallibleTo<Self, Self::Success, Infallible>
Assert that this optics should never fail (in practice). The resulting optics panics on error.
sourcefn to_str_err(self) -> MapFallibleTo<Self, Self::Success, String>
fn to_str_err(self) -> MapFallibleTo<Self, Self::Success, String>
Map the Error
type to Box<str>
.