AndExt

Trait AndExt 

Source
pub trait AndExt<I, O, E, R> {
    // Provided methods
    fn and<O2, R2, P>(self, p: P) -> And<Self, P, O, O2, R>
       where Self: Sized,
             O: Extend<O2>,
             O2: HList,
             P: Pipe<R, O2, E, R2> { ... }
    fn and_other<O2, R2, P>(self, p: P) -> AndOther<Self, P, O, R>
       where Self: Sized,
             P: Pipe<R, O2, E, R2> { ... }
    fn and_self<O2, R2, P>(self, other: P) -> AndSelf<Self, P, R, O2>
       where Self: Sized,
             P: Pipe<R, O2, E, R2> { ... }
}
Expand description

Combinator that chains 2 pipes together

Provided Methods§

Source

fn and<O2, R2, P>(self, p: P) -> And<Self, P, O, O2, R>
where Self: Sized, O: Extend<O2>, O2: HList, P: Pipe<R, O2, E, R2>,

Chains 2 Pipes one after another

The 2 output are combined into a single HList

Example:

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

assert_eq!(
    tag::<Error, _, _>("foo").and(tag("boo")).apply("foobar"),
    Err(FatalError::Error(Error::Tag(TagStrError("boo".into(), "bar".into()))))
);

assert_eq!(
    tag::<Error, _, _>("foo").and(tag("boo")).apply("foobo"),
    Err(FatalError::Error(Error::Incomplete(Incomplete::Size(1))))
);
Source

fn and_other<O2, R2, P>(self, p: P) -> AndOther<Self, P, O, R>
where Self: Sized, P: Pipe<R, O2, E, R2>,

Chains 2 Pipes one after another

Only the output of the second pipe is returned

Example:

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

fn and_self<O2, R2, P>(self, other: P) -> AndSelf<Self, P, R, O2>
where Self: Sized, P: Pipe<R, O2, E, R2>,

Chains 2 Pipes one after another

Only the output of the first pipe is returned

Example:

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

Implementors§

Source§

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