fn chain<T, U, P: Parser<I, U, Error = Self::Error>>(self, other: P) -> Map<Then<Self, P>, fn((O, U)) -> Vec<T>, (O, U)>
    where
        Self: Sized,
        U: Chain<T>,
        O: Chain<T>,
    {
        self.then(other).map(|(a, b)| {
            let mut v = Vec::with_capacity(a.len() + b.len());
            a.append_to(&mut v);
            b.append_to(&mut v);
            v
        })
    }
/// Parse one thing and then another thing, attempting to chain the two outputs into a [`Vec`].
///
/// # Examples
///
/// ```
/// # use chumsky::{prelude::*, error::Cheap};
/// let int = just('-').or_not()
///     .chain(filter::<_, _, Cheap<char>>(|c: &char| c.is_ascii_digit() && *c != '0')
///         .chain(filter::<_, _, Cheap<char>>(|c: &char| c.is_ascii_digit()).repeated()))
///     .or(just('0').map(|c| vec![c]))
///     .then_ignore(end())
///     .collect::<String>()
///     .map(|s| s.parse().unwrap());
///
/// assert_eq!(int.parse("0"), Ok(0));
/// assert_eq!(int.parse("415"), Ok(415));
/// assert_eq!(int.parse("-50"), Ok(-50));
/// assert!(int.parse("-0").is_err());
/// assert!(int.parse("05").is_err());
/// ```
Parse one thing and then another thing, attempting to chain the two outputs into a [`Vec`].
Parse one thing and then another thing attempting to chain the two outputs into a [ ` Vec ` ] .
fn chain<T, U, P: Parser<I, U, Error = Self::Error>>(self, other: P) -> Map<Then<Self, P>, fn((O, U)) -> Vec<T>, (O, U)>
    where
        Self: Sized,
        U: Chain<T>,
        O: Chain<T>,
    {
        self.then(other).map(|(a, b)| {
            let mut v = Vec::with_capacity(a.len() + b.len());
            a.append_to(&mut v);
            b.append_to(&mut v);
            v
        })
    }
fn chain < T , U , P : Parser < I , U , Error = Self :: Error > > ( self , other : P ) -> Map < Then < Self , P > , fn ( ( O , U ) ) -> Vec < T > , ( O , U ) > where Self : Sized , U : Chain < T > , O : Chain < T > , { self . then ( other ) . map ( | ( a , b ) | { let mut v = Vec :: with_capacity ( a . len ( ) + b . len ( ) ) ; a . append_to ( & mut v ) ; b . append_to ( & mut v ) ; v } ) }
Parse one thing and then another thing, attempting to chain the two outputs into a [`Vec`].
Parse one thing and then another thing attempting to chain the two outputs into a [ ` Vec ` ] .
self
other
P
examples
None
use chumsky::{prelude::*, error::cheap};
None