pub trait TryMapFn<In, Out, Err>: FnMut(In) -> Result<Out, Err> { }Expand description
Fallible variant of MapFn, with the error type as a third parameter.
use spate_core::deser::RecFamily;
use spate_core::ops::TryMapFn;
use std::num::ParseIntError;
struct LogEvent<'buf> {
line: &'buf str,
}
struct LogF;
impl RecFamily for LogF {
type Rec<'buf> = LogEvent<'buf>;
}
fn numeric_only<'a>(ev: LogEvent<'a>) -> Result<LogEvent<'a>, ParseIntError> {
ev.line.parse::<u32>()?;
Ok(ev)
}
fn try_stage<F, G, E>(g: G) -> G
where
F: RecFamily,
G: for<'buf> TryMapFn<F::Rec<'buf>, F::Rec<'buf>, E>,
E: std::fmt::Display,
{
g
}
let _ = try_stage::<LogF, _, ParseIntError>(numeric_only);Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".