pub trait ResultExt<T, E: Error>: Result<T, E> {
fn or_warn<D: From<E> + Error>(self, warn: &mut impl Warn<D>) -> Option<T>;
fn or_warn_map<D: Error>(
self,
func: impl FnOnce(E) -> D,
warn: &mut impl Warn<D>
) -> Option<T>;
}
Expand description
Integration between Result
and Warn
Note that this trait is sealed, so it is implemented for Result<T, E>
and cannot
be implemented for anything else.
Required Methods
Pass the error from result to the sink
If the result contains a value, then this value is returned. Otherwise, the error
is passed to warn
, and None
is returned. The error also can be converted to a
corresponding type via From
trait before passing into warn
.
Same as ResultExt::or_warn()
, but func
is applied to error before passing
into warn