MCPcopy Create free account
hub / github.com/dprint/jsonc-parser / scan

Method scan

src/parser.rs:62–81  ·  view source on GitHub ↗

Scans the next non-comment token. Returns a pending token if one was put back via `put_back`.

(&mut self)

Source from the content-addressed store, hash-verified

60 /// Scans the next non-comment token. Returns a pending token if one
61 /// was put back via `put_back`.
62 pub fn scan(&mut self) -> Result<Option<Token<'a>>, ParseError> {
63 if let Some(token) = self.pending_token.take() {
64 return Ok(Some(token));
65 }
66 loop {
67 match self.scanner.scan()? {
68 Some(Token::CommentLine(_) | Token::CommentBlock(_)) => {
69 if !self.allow_comments {
70 return Err(
71 self
72 .scanner
73 .create_error_for_current_token(ParseErrorKind::CommentsNotAllowed),
74 );
75 }
76 continue;
77 }
78 token => return Ok(token),
79 }
80 }
81 }
82
83 /// Puts a token back so the next `scan()` returns it.
84 #[cfg(feature = "serde")]

Callers 14

parse_to_valueFunction · 0.45
parse_objectFunction · 0.45
parse_arrayFunction · 0.45
parse_to_serde_valueFunction · 0.45
deserialize_anyMethod · 0.45
deserialize_optionMethod · 0.45
deserialize_enumMethod · 0.45
next_element_seedMethod · 0.45
tuple_variantMethod · 0.45
struct_variantMethod · 0.45
scan_object_entryMethod · 0.45
scan_object_colonMethod · 0.45

Calls 2

takeMethod · 0.45

Tested by

no test coverage detected