fn parse_unicode(input: Span) -> ParseResult<char> {
    // `take_while_m_n` parses between `m` and `n` bytes (inclusive) that match
    // a predicate. `parse_hex` here parses between 1 and 6 hexadecimal numerals.
    let parse_hex = take_while_m_n(1, 6, |c: char| c.is_ascii_hexdigit());

    // `preceeded` takes a prefix parser, and if it succeeds, returns the result
    // of the body parser. In this case, it parses u{XXXX}.
    let parse_delimited_hex = preceded(
        char('u'),
        // `delimited` is like `preceded`, but it parses both a prefix and a suffix.
        // It returns the result of the middle parser. In this case, it parses
        // {XXXX}, where XXXX is 1 to 6 hex numerals, and returns XXXX
        delimited(char('{'), parse_hex, char('}')),
    );

    // `map_res` takes the result of a parser and applies a function that returns
    // a Result. In this case we take the hex bytes from parse_hex and attempt to
    // convert them to a u32.
    let parse_u32 = map_res(parse_delimited_hex, move |hex: Span| {
        u32::from_str_radix(hex.fragment(), 16)
    });

    // map_opt is like map_res, but it takes an Option instead of a Result. If
    // the function returns None, map_opt returns an error. In this case, because
    // not all u32 values are valid unicode code points, we have to fallibly
    // convert to char with from_u32.
    map_opt(parse_u32, std::char::from_u32)(input)
}
/// Parse a unicode sequence, of the form u{XXXX}, where XXXX is 1 to 6
/// hexadecimal numerals. We will combine this later with parse_escaped_char
/// to parse sequences like \u{00AC}.
Parse a unicode sequence, of the form u{XXXX}, where XXXX is 1 to 6
hexadecimal numerals. We will combine this later with parse_escaped_char
to parse sequences like \u{00AC}.
Parse a unicode sequence of the form u { XXXX } where XXXX is 1 to 6 hexadecimal numerals . We will combine this later with parse_escaped_char to parse sequences like \ u { 00AC } .
fn parse_unicode(input: Span) -> ParseResult<char> {
    // `take_while_m_n` parses between `m` and `n` bytes (inclusive) that match
    // a predicate. `parse_hex` here parses between 1 and 6 hexadecimal numerals.
    let parse_hex = take_while_m_n(1, 6, |c: char| c.is_ascii_hexdigit());
    // `preceeded` takes a prefix parser, and if it succeeds, returns the result
    // of the body parser. In this case, it parses u{XXXX}.
    let parse_delimited_hex = preceded(
        char('u'),
        // `delimited` is like `preceded`, but it parses both a prefix and a suffix.
        // It returns the result of the middle parser. In this case, it parses
        // {XXXX}, where XXXX is 1 to 6 hex numerals, and returns XXXX
        delimited(char('{'), parse_hex, char('}')),
    );
    // `map_res` takes the result of a parser and applies a function that returns
    // a Result. In this case we take the hex bytes from parse_hex and attempt to
    // convert them to a u32.
    let parse_u32 = map_res(parse_delimited_hex, move |hex: Span| {
        u32::from_str_radix(hex.fragment(), 16)
    });
    // map_opt is like map_res, but it takes an Option instead of a Result. If
    // the function returns None, map_opt returns an error. In this case, because
    // not all u32 values are valid unicode code points, we have to fallibly
    // convert to char with from_u32.
    map_opt(parse_u32, std::char::from_u32)(input)
}
fn parse_unicode ( input : Span ) -> ParseResult < char > { // `take_while_m_n` parses between `m` and `n` bytes (inclusive) that match // a predicate. `parse_hex` here parses between 1 and 6 hexadecimal numerals. let parse_hex = take_while_m_n ( 1 , 6 , | c : char | c . is_ascii_hexdigit ( ) ) ; // `preceeded` takes a prefix parser, and if it succeeds, returns the result // of the body parser. In this case, it parses u{XXXX}. let parse_delimited_hex = preceded ( char ( 'u' ) , // `delimited` is like `preceded`, but it parses both a prefix and a suffix. // It returns the result of the middle parser. In this case, it parses // {XXXX}, where XXXX is 1 to 6 hex numerals, and returns XXXX delimited ( char ( '{' ) , parse_hex , char ( '}' ) ) , ) ; // `map_res` takes the result of a parser and applies a function that returns // a Result. In this case we take the hex bytes from parse_hex and attempt to // convert them to a u32. let parse_u32 = map_res ( parse_delimited_hex , move | hex : Span | { u32 :: from_str_radix ( hex . fragment ( ) , 16 ) } ) ; // map_opt is like map_res, but it takes an Option instead of a Result. If // the function returns None, map_opt returns an error. In this case, because // not all u32 values are valid unicode code points, we have to fallibly // convert to char with from_u32. map_opt ( parse_u32 , std :: char :: from_u32 ) ( input ) }
Parse a unicode sequence, of the form u{XXXX}, where XXXX is 1 to 6
hexadecimal numerals.
Parse a unicode sequence of the form u { XXXX } where XXXX is 1 to 6 hexadecimal numerals .
input
Span