Function winnow::bytes::streaming::is_a

source ·
pub fn is_a<T, I, Error: ParseError<I>>(
    arr: 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_while1</code> with input wrapped in <code>winnow::Partial</code>
Expand description

Returns the longest slice of the matches the pattern.

The parser will return the longest slice consisting of the characters in provided in the combinator’s argument.

Partial specific

Partial version will return a ErrMode::Incomplete(Needed::new(1)) if the pattern wasn’t met or if the pattern reaches the end of the input.

Example

use winnow::bytes::streaming::is_a;

fn hex(s: &str) -> IResult<&str, &str> {
  is_a("1234567890ABCDEF")(s)
}

assert_eq!(hex("123 and voila"), Ok((" and voila", "123")));
assert_eq!(hex("DEADBEEF and others"), Ok((" and others", "DEADBEEF")));
assert_eq!(hex("BADBABEsomething"), Ok(("something", "BADBABE")));
assert_eq!(hex("D15EA5E"), Err(ErrMode::Incomplete(Needed::new(1))));
assert_eq!(hex(""), Err(ErrMode::Incomplete(Needed::new(1))));

WARNING: Deprecated, replaced with winnow::bytes::take_while1 with input wrapped in winnow::Partial