Skip to main content

css_lexer/
cursor.rs

1use crate::{AssociatedWhitespaceRules, CommentStyle, Cursor, Kind, KindSet, QuoteStyle, Token};
2
3impl From<Cursor> for Token {
4	fn from(cursor: Cursor) -> Self {
5		cursor.token()
6	}
7}
8
9impl PartialEq<Token> for Cursor {
10	fn eq(&self, other: &Token) -> bool {
11		self.token() == *other
12	}
13}
14
15impl From<Cursor> for Kind {
16	fn from(cursor: Cursor) -> Self {
17		cursor.token().kind()
18	}
19}
20
21impl PartialEq<Kind> for Cursor {
22	fn eq(&self, other: &Kind) -> bool {
23		self.token() == *other
24	}
25}
26
27impl PartialEq<CommentStyle> for Cursor {
28	fn eq(&self, other: &CommentStyle) -> bool {
29		self.token() == *other
30	}
31}
32
33impl From<Cursor> for KindSet {
34	fn from(cursor: Cursor) -> Self {
35		cursor.token().into()
36	}
37}
38
39impl PartialEq<KindSet> for Cursor {
40	fn eq(&self, other: &KindSet) -> bool {
41		self.token() == *other
42	}
43}
44
45impl From<Cursor> for QuoteStyle {
46	fn from(cursor: Cursor) -> Self {
47		cursor.token().into()
48	}
49}
50
51impl PartialEq<QuoteStyle> for Cursor {
52	fn eq(&self, other: &QuoteStyle) -> bool {
53		self.token() == *other
54	}
55}
56
57impl PartialEq<AssociatedWhitespaceRules> for Cursor {
58	fn eq(&self, other: &AssociatedWhitespaceRules) -> bool {
59		self.token() == *other
60	}
61}
62
63impl PartialEq<CommentStyle> for &Cursor {
64	fn eq(&self, other: &CommentStyle) -> bool {
65		self.token() == *other
66	}
67}
68
69impl PartialEq<Kind> for &Cursor {
70	fn eq(&self, other: &Kind) -> bool {
71		self.token() == *other
72	}
73}
74
75impl PartialEq<KindSet> for &Cursor {
76	fn eq(&self, other: &KindSet) -> bool {
77		self.token() == *other
78	}
79}
80
81impl PartialEq<QuoteStyle> for &Cursor {
82	fn eq(&self, other: &QuoteStyle) -> bool {
83		self.token() == *other
84	}
85}
86
87#[test]
88fn size_test() {
89	assert_eq!(::std::mem::size_of::<Cursor>(), 12);
90}