fn string_char(&mut self) -> Result<char, Error> {
      let c = self.get();
      self.advance();
      Ok(match c {
         '\\' => {
            let escape = self.get();
            let escape_char_location = self.location;
            self.advance();
            match escape {
               '\'' => '\'',
               '"' => '"',
               '\\' => '\\',
               'n' => '\n',
               'r' => '\r',
               't' => '\t',
               'u' => {
                  let left_brace_location = self.location;
                  if self.get() != '{' {
                     return Err(self.error(ErrorKind::UEscapeLeftBraceExpected));
                  }
                  self.advance();
                  let digits_location = self.location;
                  let mut number = String::new();
                  self.collect_digits(&mut number, 16)?;
                  if self.get() != '}' {
                     return Err(
                        self.error_at(left_brace_location, ErrorKind::UEscapeMissingRightBrace),
                     );
                  }
                  self.advance();
                  if number.is_empty() {
                     return Err(self.error_at(digits_location, ErrorKind::UEscapeEmpty));
                  }
                  // The only error here is guaranteed to be overflow.
                  let scalar_value = u32::from_str_radix(&number, 16)
                     .map_err(|_| self.error_at(digits_location, ErrorKind::UEscapeOutOfRange))?;
                  char::try_from(scalar_value)
                     .map_err(|_| self.error_at(digits_location, ErrorKind::UEscapeOutOfRange))?
               }
               other => {
                  return Err(self.error_at(escape_char_location, ErrorKind::InvalidEscape(other)))
               }
            }
         }
         other => other,
      })
   }
/// Parses a character inside of a string.
Parses a character inside of a string.
Parses a character inside of a string .
fn string_char(&mut self) -> Result<char, Error> {
      let c = self.get();
      self.advance();
      Ok(match c {
         '\\' => {
            let escape = self.get();
            let escape_char_location = self.location;
            self.advance();
            match escape {
               '\'' => '\'',
               '"' => '"',
               '\\' => '\\',
               'n' => '\n',
               'r' => '\r',
               't' => '\t',
               'u' => {
                  let left_brace_location = self.location;
                  if self.get() != '{' {
                     return Err(self.error(ErrorKind::UEscapeLeftBraceExpected));
                  }
                  self.advance();
                  let digits_location = self.location;
                  let mut number = String::new();
                  self.collect_digits(&mut number, 16)?;
                  if self.get() != '}' {
                     return Err(
                        self.error_at(left_brace_location, ErrorKind::UEscapeMissingRightBrace),
                     );
                  }
                  self.advance();
                  if number.is_empty() {
                     return Err(self.error_at(digits_location, ErrorKind::UEscapeEmpty));
                  }
                  // The only error here is guaranteed to be overflow.
                  let scalar_value = u32::from_str_radix(&number, 16)
                     .map_err(|_| self.error_at(digits_location, ErrorKind::UEscapeOutOfRange))?;
                  char::try_from(scalar_value)
                     .map_err(|_| self.error_at(digits_location, ErrorKind::UEscapeOutOfRange))?
               }
               other => {
                  return Err(self.error_at(escape_char_location, ErrorKind::InvalidEscape(other)))
               }
            }
         }
         other => other,
      })
   }
fn string_char ( & mut self ) -> Result < char , Error > { let c = self . get ( ) ; self . advance ( ) ; Ok ( match c { '\\' => { let escape = self . get ( ) ; let escape_char_location = self . location ; self . advance ( ) ; match escape { '\'' => '\'' , '"' => '"' , '\\' => '\\' , 'n' => '\n' , 'r' => '\r' , 't' => '\t' , 'u' => { let left_brace_location = self . location ; if self . get ( ) != '{' { return Err ( self . error ( ErrorKind :: UEscapeLeftBraceExpected ) ) ; } self . advance ( ) ; let digits_location = self . location ; let mut number = String :: new ( ) ; self . collect_digits ( & mut number , 16 ) ? ; if self . get ( ) != '}' { return Err ( self . error_at ( left_brace_location , ErrorKind :: UEscapeMissingRightBrace ) , ) ; } self . advance ( ) ; if number . is_empty ( ) { return Err ( self . error_at ( digits_location , ErrorKind :: UEscapeEmpty ) ) ; } // The only error here is guaranteed to be overflow. let scalar_value = u32 :: from_str_radix ( & number , 16 ) . map_err ( | _ | self . error_at ( digits_location , ErrorKind :: UEscapeOutOfRange ) ) ? ; char :: try_from ( scalar_value ) . map_err ( | _ | self . error_at ( digits_location , ErrorKind :: UEscapeOutOfRange ) ) ? } other => { return Err ( self . error_at ( escape_char_location , ErrorKind :: InvalidEscape ( other ) ) ) } } } other => other , } ) }
Parses a character inside of a string.
Parses a character inside of a string .
&mut self