pub(super) fn parse_char_escape(
    it: &mut Peekable<impl Iterator<Item = (usize, char)>>,
    with_template: WithTemplate,
    with_line_cont: WithLineCont,
) -> Result<Option<char>, ResolveErrorKind> {
    let (_, c) = it.next().ok_or(ResolveErrorKind::BadEscapeSequence)?;

    Ok(Some(match c {
        '\n' | '\r' if *with_line_cont => {
            while let Some((_, c)) = it.peek() {
                if !char::is_whitespace(*c) {
                    break;
                }

                it.next();
            }

            return Ok(None);
        }
        '$' if *with_template => '$',
        '`' if *with_template => '`',
        '\'' => '\'',
        '\"' => '\"',
        'n' => '\n',
        'r' => '\r',
        't' => '\t',
        '\\' => '\\',
        '0' => '\0',
        'x' => {
            let result = parse_hex_escape(it)?;

            if result > 0x7f {
                return Err(ResolveErrorKind::BadHexEscapeChar);
            }

            if let Some(c) = std::char::from_u32(result) {
                c
            } else {
                return Err(ResolveErrorKind::BadByteEscape);
            }
        }
        'u' => parse_unicode_escape(it)?,
        _ => {
            return Err(ResolveErrorKind::BadEscapeSequence);
        }
    }))
}
/// Parse a byte escape sequence.
Parse a byte escape sequence.
Parse a byte escape sequence .
pub(super) fn parse_char_escape(
    it: &mut Peekable<impl Iterator<Item = (usize, char)>>,
    with_template: WithTemplate,
    with_line_cont: WithLineCont,
) -> Result<Option<char>, ResolveErrorKind> {
    let (_, c) = it.next().ok_or(ResolveErrorKind::BadEscapeSequence)?;
    Ok(Some(match c {
        '\n' | '\r' if *with_line_cont => {
            while let Some((_, c)) = it.peek() {
                if !char::is_whitespace(*c) {
                    break;
                }
                it.next();
            }
            return Ok(None);
        }
        '$' if *with_template => '$',
        '`' if *with_template => '`',
        '\'' => '\'',
        '\"' => '\"',
        'n' => '\n',
        'r' => '\r',
        't' => '\t',
        '\\' => '\\',
        '0' => '\0',
        'x' => {
            let result = parse_hex_escape(it)?;
            if result > 0x7f {
                return Err(ResolveErrorKind::BadHexEscapeChar);
            }
            if let Some(c) = std::char::from_u32(result) {
                c
            } else {
                return Err(ResolveErrorKind::BadByteEscape);
            }
        }
        'u' => parse_unicode_escape(it)?,
        _ => {
            return Err(ResolveErrorKind::BadEscapeSequence);
        }
    }))
}
pub ( super ) fn parse_char_escape ( it : & mut Peekable < impl Iterator < Item = ( usize , char ) > > , with_template : WithTemplate , with_line_cont : WithLineCont , ) -> Result < Option < char > , ResolveErrorKind > { let ( _ , c ) = it . next ( ) . ok_or ( ResolveErrorKind :: BadEscapeSequence ) ? ; Ok ( Some ( match c { '\n' | '\r' if * with_line_cont => { while let Some ( ( _ , c ) ) = it . peek ( ) { if ! char :: is_whitespace ( * c ) { break ; } it . next ( ) ; } return Ok ( None ) ; } '$' if * with_template => '$' , '`' if * with_template => '`' , '\'' => '\'' , '\"' => '\"' , 'n' => '\n' , 'r' => '\r' , 't' => '\t' , '\\' => '\\' , '0' => '\0' , 'x' => { let result = parse_hex_escape ( it ) ? ; if result > 0x7f { return Err ( ResolveErrorKind :: BadHexEscapeChar ) ; } if let Some ( c ) = std :: char :: from_u32 ( result ) { c } else { return Err ( ResolveErrorKind :: BadByteEscape ) ; } } 'u' => parse_unicode_escape ( it ) ? , _ => { return Err ( ResolveErrorKind :: BadEscapeSequence ) ; } } ) ) }
Parse a byte escape sequence.
Parse a byte escape sequence .
it
&mut Peekable<impl Iterator<Item = (usize, char)>>
with_template
WithTemplate
with_line_cont
WithLineCont
it
&mut Peekable<impl Iterator<Item = (usize, char)>>
with_template
WithTemplate
with_line_cont
WithLineCont