pub trait WrapExt<I, O, E, R> {
// Provided method
fn wrap<I2, O2, R2, F>(self, f: F) -> Wrap<I, O, R, Self, F>
where Self: Pipe<I, O, E, R> + Sized,
F: FnMut(&mut Self, I2) -> Result<R2, O2, E> { ... }
}Expand description
Wraps the pipe and input/ouput into a closure
Provided Methods§
Sourcefn wrap<I2, O2, R2, F>(self, f: F) -> Wrap<I, O, R, Self, F>
fn wrap<I2, O2, R2, F>(self, f: F) -> Wrap<I, O, R, Self, F>
wraps self into a function
pub fn input_offset<'a, O, E>(
p: &mut impl Pipe<&'a str, O, E>, input: (&'a str, usize),
) -> Result<(&'a str, usize), O, E> {
let (i, o) = p.apply(input.0)?;
Ok(((i, input.1 + (input.0.len() - i.len())), o))
}
assert_eq!(
tag::<Error, _, _>("foo").and(tag("bar")).wrap(input_offset).apply(("foobar", 0)),
Ok((("", 6), ("foo", "bar")))
);
assert_eq!(
tag::<Error, _, _>("foo").and(tag("bar")).wrap(input_offset).apply(("foobar", 0)),
Ok((("", 6), ("foo", "bar")))
);