SkipExt

Trait SkipExt 

Source
pub trait SkipExt<I, O, E, R> {
    // Provided methods
    fn skip(self) -> Skip<Self, O>
       where Self: Sized { ... }
    fn and_skip<O2, R2, P>(self, other: P) -> AndSkip<Self, P, O, O2, R>
       where Self: Sized,
             P: Pipe<R, O2, E, R2> { ... }
    fn or_skip<O2, P>(self, p: P) -> OrSkip<O, O2, Self, P>
       where Self: Sized,
             I: Clone,
             P: Pipe<I, O2, E, R> { ... }
}
Expand description

Combinator that discards output

Provided Methods§

Source

fn skip(self) -> Skip<Self, O>
where Self: Sized,

Discards the output of the pipe

Example:

assert_eq!(tag::<Error, _, _>("foo").skip().apply("foobar"), Ok(("bar", ())));

assert_eq!(
    tag::<Error, _, _>("foo").skip().apply("something"),
    Err(FatalError::Error(Error::Tag(TagStrError("foo".into(), "som".into()))))
);
Source

fn and_skip<O2, R2, P>(self, other: P) -> AndSkip<Self, P, O, O2, R>
where Self: Sized, P: Pipe<R, O2, E, R2>,

Chains 2 Pipes one after another both output are discarded

Example:

assert_eq!(
    tag::<Error, _, _>("foo").and_skip(tag("bar")).apply("foobar"),
    Ok(("", ()))
);

assert_eq!(
    tag::<Error, _, _>("foo").and_skip(tag("boo")).apply("something"),
    Err(FatalError::Error(Error::Tag(TagStrError("foo".into(), "som".into()))))
);
Source

fn or_skip<O2, P>(self, p: P) -> OrSkip<O, O2, Self, P>
where Self: Sized, I: Clone, P: Pipe<I, O2, E, R>,

Apply the second Pipe if the first fails discarding both output

Example:

assert_eq!(tag::<Error, _, _>("foo").or_skip(tag("bar")).apply("foo"), Ok(("", ())));

assert_eq!(tag::<Error, _, _>("foo").or_skip(tag("boo")).apply("boo"), Ok(("", ())));

assert_eq!(
    tag::<Error, _, _>("foo").or_skip(tag("boo")).apply("something"),
    Err(FatalError::Error(Error::Tag(TagStrError("boo".into(), "som".into()))))
);

Implementors§

Source§

impl<I, O, E, R, P> SkipExt<I, O, E, R> for P
where P: Pipe<I, O, E, R>,