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

Method append

crates/css_parse/src/cursor_interleave_sink.rs:29–66  ·  view source on GitHub ↗
(&mut self, c: Cursor)

Source from the content-addressed store, hash-verified

27
28impl<'a, S: CursorSink> CursorSink for CursorInterleaveSink<'a, S> {
29 fn append(&mut self, c: Cursor) {
30 #[cfg(debug_assertions)]
31 {
32 debug_assert!(!self.seen_eof, "Received cursor after EOF: {:?}", c);
33 if c == Kind::Eof {
34 self.seen_eof = true;
35 }
36 }
37
38 // Check if this content cursor has associated trivia
39 while self.current_index < self.interleave.len() {
40 let (trivia, associated_cursor) = &self.interleave[self.current_index];
41 if *associated_cursor == c {
42 for cursor in trivia {
43 self.sink.append(*cursor);
44 }
45 self.current_index += 1;
46 break;
47 }
48 if associated_cursor.span().start() > c.span().start() {
49 break;
50 }
51 self.current_index += 1;
52 }
53
54 // If this is EOF, flush any remaining trivia before emitting EOF
55 if c == Kind::Eof {
56 while self.current_index < self.interleave.len() {
57 let (trivia, _) = &self.interleave[self.current_index];
58 for cursor in trivia {
59 self.sink.append(*cursor);
60 }
61 self.current_index += 1;
62 }
63 }
64
65 self.sink.append(c);
66 }
67}

Callers

nothing calls this directly

Calls 3

lenMethod · 0.45
startMethod · 0.45
spanMethod · 0.45

Tested by

no test coverage detected