css_parse/
parser_checkpoint.rs1use crate::{Cursor, Kind, Span, ToSpan, Token};
2
3#[derive(Debug, Default, Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
8pub struct ParserCheckpoint {
9 pub(crate) cursor: Cursor,
10 pub(crate) errors_pos: u8,
11 pub(crate) trivia_pos: u16,
12}
13
14impl From<ParserCheckpoint> for Cursor {
15 fn from(value: ParserCheckpoint) -> Self {
16 value.cursor
17 }
18}
19
20impl From<ParserCheckpoint> for Token {
21 fn from(value: ParserCheckpoint) -> Self {
22 value.cursor.token()
23 }
24}
25
26impl From<ParserCheckpoint> for Kind {
27 fn from(value: ParserCheckpoint) -> Self {
28 value.cursor.token().kind()
29 }
30}
31
32impl ToSpan for ParserCheckpoint {
33 fn to_span(&self) -> Span {
34 self.cursor.span()
35 }
36}
37
38#[cfg(test)]
39mod test {
40 use super::*;
41
42 #[test]
43 fn size_test() {
44 assert_eq!(std::mem::size_of::<ParserCheckpoint>(), 16);
45 }
46}