After an array element, scans for the comma/close-bracket and returns the next token.
(&mut self)
| 190 | /// After an array element, scans for the comma/close-bracket and |
| 191 | /// returns the next token. |
| 192 | pub fn scan_array_comma(&mut self) -> Result<Option<Token<'a>>, ParseError> { |
| 193 | let token = self.scan()?; |
| 194 | if matches!(&token, Some(Token::Comma)) { |
| 195 | let comma_range = Range::new(self.scanner.token_start(), self.scanner.token_end()); |
| 196 | let next = self.scan()?; |
| 197 | if matches!(&next, Some(Token::CloseBracket)) && !self.allow_trailing_commas { |
| 198 | return Err( |
| 199 | self |
| 200 | .scanner |
| 201 | .create_error_for_range(comma_range, ParseErrorKind::TrailingCommasNotAllowed), |
| 202 | ); |
| 203 | } |
| 204 | Ok(next) |
| 205 | } else { |
| 206 | Ok(token) |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | fn scan_object_key(&mut self) -> Result<Option<ObjectKey<'a>>, ParseError> { |
| 211 | match self.scan()? { |
no test coverage detected