MCPcopy Create free account
hub / github.com/csskit/csskit / peek_n_with_skip

Method peek_n_with_skip

crates/css_parse/src/parser.rs:293–323  ·  view source on GitHub ↗
(&self, n: u8, skip: KindSet)

Source from the content-addressed store, hash-verified

291
292 #[inline]
293 pub(crate) fn peek_n_with_skip(&self, n: u8, skip: KindSet) -> Cursor {
294 let mut remaining = n;
295
296 for c in &self.buffer[self.buffer_index..BUFFER_LEN] {
297 if c == Kind::Eof {
298 return *c;
299 }
300 if c != skip {
301 remaining -= 1;
302 if remaining == 0 {
303 return *c;
304 }
305 }
306 }
307
308 let mut iter = self.cursor_iter.clone();
309 loop {
310 let Some(cursor) = iter.next() else {
311 return eof_cursor(self.source_text.len());
312 };
313 if cursor == Kind::Eof {
314 return cursor;
315 }
316 if cursor != skip {
317 remaining -= 1;
318 if remaining == 0 {
319 return cursor;
320 }
321 }
322 }
323 }
324
325 #[inline]
326 pub fn peek_n(&self, n: u8) -> Cursor {

Callers 5

parse_entirelyMethod · 0.80
peek_nMethod · 0.80
peekMethod · 0.80
parseMethod · 0.80

Calls 4

eof_cursorFunction · 0.85
cloneMethod · 0.80
nextMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected