nom8::bytes::streaming

Function escaped

Source
pub fn escaped<Input, Error, F, G, O1, O2>(
    normal: F,
    control_char: char,
    escapable: G,
) -> impl FnMut(Input) -> IResult<Input, <Input as IntoOutput>::Output, Error>
where Input: Clone + Offset + InputLength + InputTake + InputTakeAtPosition + Slice<RangeFrom<usize>> + InputIter + IntoOutput, <Input as InputIter>::Item: AsChar, F: Parser<Input, O1, Error>, G: Parser<Input, O2, Error>, Error: ParseError<Input>,
๐Ÿ‘ŽDeprecated since 8.0.0: Replaced with nom8::bytes::escaped with input wrapped in nom8::input::Streaming
Expand description

Matches a byte string with escaped characters.

  • The first argument matches the normal characters (it must not accept the control character)
  • The second argument is the control character (like \ in most languages)
  • The third argument matches the escaped characters

ยงExample

use nom8::bytes::streaming::escaped;
use nom8::character::streaming::one_of;

fn esc(s: &str) -> IResult<&str, &str> {
  escaped(digit1, '\\', one_of("\"n\\"))(s)
}

assert_eq!(esc("123;"), Ok((";", "123")));
assert_eq!(esc("12\\\"34;"), Ok((";", "12\\\"34")));

WARNING: Deprecated, replaced with nom8::bytes::escaped with input wrapped in nom8::input::Streaming