diff options
Diffstat (limited to 'crates/ra_syntax/src/ast/tokens.rs')
-rw-r--r-- | crates/ra_syntax/src/ast/tokens.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/crates/ra_syntax/src/ast/tokens.rs b/crates/ra_syntax/src/ast/tokens.rs index be63b3c9e..87cca325d 100644 --- a/crates/ra_syntax/src/ast/tokens.rs +++ b/crates/ra_syntax/src/ast/tokens.rs | |||
@@ -6,23 +6,23 @@ use crate::{ | |||
6 | SyntaxToken, | 6 | SyntaxToken, |
7 | }; | 7 | }; |
8 | 8 | ||
9 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 9 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
10 | pub struct Comment<'a>(SyntaxToken<'a>); | 10 | pub struct Comment(SyntaxToken); |
11 | 11 | ||
12 | impl<'a> AstToken<'a> for Comment<'a> { | 12 | impl AstToken for Comment { |
13 | fn cast(token: SyntaxToken<'a>) -> Option<Self> { | 13 | fn cast(token: SyntaxToken) -> Option<Self> { |
14 | if token.kind() == COMMENT { | 14 | if token.kind() == COMMENT { |
15 | Some(Comment(token)) | 15 | Some(Comment(token)) |
16 | } else { | 16 | } else { |
17 | None | 17 | None |
18 | } | 18 | } |
19 | } | 19 | } |
20 | fn syntax(&self) -> SyntaxToken<'a> { | 20 | fn syntax(&self) -> &SyntaxToken { |
21 | self.0 | 21 | &self.0 |
22 | } | 22 | } |
23 | } | 23 | } |
24 | 24 | ||
25 | impl<'a> Comment<'a> { | 25 | impl Comment { |
26 | pub fn kind(&self) -> CommentKind { | 26 | pub fn kind(&self) -> CommentKind { |
27 | kind_by_prefix(self.text()) | 27 | kind_by_prefix(self.text()) |
28 | } | 28 | } |
@@ -90,22 +90,22 @@ fn prefix_by_kind(kind: CommentKind) -> &'static str { | |||
90 | unreachable!() | 90 | unreachable!() |
91 | } | 91 | } |
92 | 92 | ||
93 | pub struct Whitespace<'a>(SyntaxToken<'a>); | 93 | pub struct Whitespace(SyntaxToken); |
94 | 94 | ||
95 | impl<'a> AstToken<'a> for Whitespace<'a> { | 95 | impl AstToken for Whitespace { |
96 | fn cast(token: SyntaxToken<'a>) -> Option<Self> { | 96 | fn cast(token: SyntaxToken) -> Option<Self> { |
97 | if token.kind() == WHITESPACE { | 97 | if token.kind() == WHITESPACE { |
98 | Some(Whitespace(token)) | 98 | Some(Whitespace(token)) |
99 | } else { | 99 | } else { |
100 | None | 100 | None |
101 | } | 101 | } |
102 | } | 102 | } |
103 | fn syntax(&self) -> SyntaxToken<'a> { | 103 | fn syntax(&self) -> &SyntaxToken { |
104 | self.0 | 104 | &self.0 |
105 | } | 105 | } |
106 | } | 106 | } |
107 | 107 | ||
108 | impl<'a> Whitespace<'a> { | 108 | impl Whitespace { |
109 | pub fn spans_multiple_lines(&self) -> bool { | 109 | pub fn spans_multiple_lines(&self) -> bool { |
110 | let text = self.text(); | 110 | let text = self.text(); |
111 | text.find('\n').map_or(false, |idx| text[idx + 1..].contains('\n')) | 111 | text.find('\n').map_or(false, |idx| text[idx + 1..].contains('\n')) |