Function neure::re::regex::collect

source ·
pub fn collect<'a, C, P, O>(pat: P, min: usize) -> RegexCollect<C, P, O>where
    P: Regex<C>,
    O: FromIterator<P::Ret>,
    C: Context<'a> + Match<C>,
Expand description

Match the regex P repeatedly, and collect the result into given type O.

Example

    color_eyre::install()?;
    let val = neu::ascii_alphabetic().repeat_one();
    let vec = re::collect::<_, _, Vec<_>>(val, 1);

    assert_eq!(
        CharsCtx::new("abcdf").try_mat_t(&vec)?,
        vec![
            Span::new(0, 1),
            Span::new(1, 1),
            Span::new(2, 1),
            Span::new(3, 1),
            Span::new(4, 1),
        ]
    );
    Ok(())