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§
Sourcefn skip(self) -> Skip<Self, O>where
Self: Sized,
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()))))
);Sourcefn and_skip<O2, R2, P>(self, other: P) -> AndSkip<Self, P, O, O2, R>
fn and_skip<O2, R2, P>(self, other: P) -> AndSkip<Self, P, O, O2, R>
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()))))
);Sourcefn or_skip<O2, P>(self, p: P) -> OrSkip<O, O2, Self, P>
fn or_skip<O2, P>(self, p: P) -> OrSkip<O, O2, Self, P>
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()))))
);