pub fn take_while_m_n<T, I, Error: ParseError<I>>(
    m: usize,
    n: usize,
    list: T
) -> impl Fn(I) -> IResult<I, <I as Stream>::Slice, Error>where
    I: Stream,
    T: ContainsToken<<I as Stream>::Token>,
👎Deprecated since 0.1.0: Replaced with <code>winnow::bytes::take_while_m_n</code>
Expand description

Returns the longest (m <= len <= n) input slice that matches the predicate.

The parser will return the longest slice that matches the given predicate (a function that takes the input and returns a bool).

It will return an ErrMode::Backtrack((_, ErrorKind::TakeWhileMN)) if the pattern wasn’t met or is out of range (m <= len <= n).

Example

use winnow::bytes::complete::take_while_m_n;
use winnow::stream::AsChar;

fn short_alpha(s: &[u8]) -> IResult<&[u8], &[u8]> {
  take_while_m_n(3, 6, AsChar::is_alpha)(s)
}

assert_eq!(short_alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..])));
assert_eq!(short_alpha(b"lengthy"), Ok((&b"y"[..], &b"length"[..])));
assert_eq!(short_alpha(b"latin"), Ok((&b""[..], &b"latin"[..])));
assert_eq!(short_alpha(b"ed"), Err(ErrMode::Backtrack(Error::new(&b"ed"[..], ErrorKind::TakeWhileMN))));
assert_eq!(short_alpha(b"12345"), Err(ErrMode::Backtrack(Error::new(&b"12345"[..], ErrorKind::TakeWhileMN))));

WARNING: Deprecated, replaced with winnow::bytes::take_while_m_n