fn string(&mut self) -> Result<(Span, Vec<u8>)> {
    let start = self.idx;
    if self.cur_opt() != Some(b'\"') {
      return self.err_str("expected an string literal")
    }
    self.idx += 1;
    let mut s: Vec<u8> = Vec::new();
    while self.idx < self.source.len() {
      match (self.cur(), self.idx += 1).0 {
        b'\\' => s.push(match (self.cur_opt(), self.idx += 1).0 {
          None => break,
          Some(b'\\') => b'\\',
          Some(b'n') => b'\n',
          Some(b'r') => b'\r',
          Some(b'\"') => b'\"',
          Some(b'x') | Some(b'X') if self.idx + 2 <= self.source.len() => {
            let c1 = (self.cur(), self.idx += 1).0;
            let c2 = (self.cur(), self.idx += 1).0;
            if let (Some(h1), Some(h2)) = ((c1 as char).to_digit(16), (c2 as char).to_digit(16)) {
              #[allow(clippy::cast_possible_truncation)]
              {
                (h1 << 4 | h2) as u8
              }
            } else {
              self.errors.push(ParseError {
                pos: (self.idx - 4..self.idx).into(),
                level: ErrorLevel::Warning,
                msg: "invalid hex escape".into(),
              });
              self.idx -= 3;
              b'\\'
            }
          }
          Some(_) => {
            self.errors.push(ParseError {
              pos: (self.idx - 2..self.idx).into(),
              level: ErrorLevel::Warning,
              msg: "unknown escape sequence".into(),
            });
            self.idx -= 1;
            b'\\'
          }
        }),
        b'\"' => return (Ok(((start..self.idx).into(), s)), self.ws()).0,
        c => s.push(c),
      }
    }
    Err(ParseError::new(
      start..mem::replace(&mut self.idx, start),
      "unclosed string literal".into(),
    ))
  }
/// Try to parse a string literal beginning at the current parser position.
/// Returns the span of the string literal (including the quotes), and the parsed string,
/// and returns a failure if the string is not well formed or if there is no
/// string at the current position.
Try to parse a string literal beginning at the current parser position.
Returns the span of the string literal (including the quotes), and the parsed string,
and returns a failure if the string is not well formed or if there is no
string at the current position.
Try to parse a string literal beginning at the current parser position . Returns the span of the string literal ( including the quotes ) and the parsed string and returns a failure if the string is not well formed or if there is no string at the current position .
fn string(&mut self) -> Result<(Span, Vec<u8>)> {
    let start = self.idx;
    if self.cur_opt() != Some(b'\"') {
      return self.err_str("expected an string literal")
    }
    self.idx += 1;
    let mut s: Vec<u8> = Vec::new();
    while self.idx < self.source.len() {
      match (self.cur(), self.idx += 1).0 {
        b'\\' => s.push(match (self.cur_opt(), self.idx += 1).0 {
          None => break,
          Some(b'\\') => b'\\',
          Some(b'n') => b'\n',
          Some(b'r') => b'\r',
          Some(b'\"') => b'\"',
          Some(b'x') | Some(b'X') if self.idx + 2 <= self.source.len() => {
            let c1 = (self.cur(), self.idx += 1).0;
            let c2 = (self.cur(), self.idx += 1).0;
            if let (Some(h1), Some(h2)) = ((c1 as char).to_digit(16), (c2 as char).to_digit(16)) {
              #[allow(clippy::cast_possible_truncation)]
              {
                (h1 << 4 | h2) as u8
              }
            } else {
              self.errors.push(ParseError {
                pos: (self.idx - 4..self.idx).into(),
                level: ErrorLevel::Warning,
                msg: "invalid hex escape".into(),
              });
              self.idx -= 3;
              b'\\'
            }
          }
          Some(_) => {
            self.errors.push(ParseError {
              pos: (self.idx - 2..self.idx).into(),
              level: ErrorLevel::Warning,
              msg: "unknown escape sequence".into(),
            });
            self.idx -= 1;
            b'\\'
          }
        }),
        b'\"' => return (Ok(((start..self.idx).into(), s)), self.ws()).0,
        c => s.push(c),
      }
    }
    Err(ParseError::new(
      start..mem::replace(&mut self.idx, start),
      "unclosed string literal".into(),
    ))
  }
fn string ( & mut self ) -> Result < ( Span , Vec < u8 > ) > { let start = self . idx ; if self . cur_opt ( ) != Some ( b'\"' ) { return self . err_str ( " " ) } self . idx += 1 ; let mut s : Vec < u8 > = Vec :: new ( ) ; while self . idx < self . source . len ( ) { match ( self . cur ( ) , self . idx += 1 ) . 0 { b'\\' => s . push ( match ( self . cur_opt ( ) , self . idx += 1 ) . 0 { None => break , Some ( b'\\' ) => b'\\' , Some ( b'n' ) => b'\n' , Some ( b'r' ) => b'\r' , Some ( b'\"' ) => b'\"' , Some ( b'x' ) | Some ( b'X' ) if self . idx + 2 <= self . source . len ( ) => { let c1 = ( self . cur ( ) , self . idx += 1 ) . 0 ; let c2 = ( self . cur ( ) , self . idx += 1 ) . 0 ; if let ( Some ( h1 ) , Some ( h2 ) ) = ( ( c1 as char ) . to_digit ( 16 ) , ( c2 as char ) . to_digit ( 16 ) ) { # [ allow ( clippy cast_possible_truncation ) ] { ( h1 << 4 | h2 ) as u8 } } else { self . errors . push ( ParseError { pos : ( self . idx - 4 .. self . idx ) . into ( ) , level : ErrorLevel :: Warning , msg : " " . into ( ) , } ) ; self . idx -= 3 ; b'\\' } } Some ( _ ) => { self . errors . push ( ParseError { pos : ( self . idx - 2 .. self . idx ) . into ( ) , level : ErrorLevel :: Warning , msg : " " . into ( ) , } ) ; self . idx -= 1 ; b'\\' } } ) , b'\"' => return ( Ok ( ( ( start .. self . idx ) . into ( ) , s ) ) , self . ws ( ) ) . 0 , c => s . push ( c ) , } } Err ( ParseError :: new ( start .. mem :: replace ( & mut self . idx , start ) , " " . into ( ) , ) ) }
Try to parse a string literal beginning at the current parser position.
Try to parse a string literal beginning at the current parser position .
&mut self
&mut self