aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/ast/tokens.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_syntax/src/ast/tokens.rs')
-rw-r--r--crates/ra_syntax/src/ast/tokens.rs26
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)]
10pub struct Comment<'a>(SyntaxToken<'a>); 10pub struct Comment(SyntaxToken);
11 11
12impl<'a> AstToken<'a> for Comment<'a> { 12impl 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
25impl<'a> Comment<'a> { 25impl 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
93pub struct Whitespace<'a>(SyntaxToken<'a>); 93pub struct Whitespace(SyntaxToken);
94 94
95impl<'a> AstToken<'a> for Whitespace<'a> { 95impl 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
108impl<'a> Whitespace<'a> { 108impl 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'))