aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_syntax/src/ast/tokens.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/crates/ra_syntax/src/ast/tokens.rs b/crates/ra_syntax/src/ast/tokens.rs
index 481813e38..74906d8a6 100644
--- a/crates/ra_syntax/src/ast/tokens.rs
+++ b/crates/ra_syntax/src/ast/tokens.rs
@@ -13,7 +13,12 @@ impl Comment {
13 } 13 }
14 14
15 pub fn prefix(&self) -> &'static str { 15 pub fn prefix(&self) -> &'static str {
16 prefix_by_kind(self.kind()) 16 for (prefix, k) in COMMENT_PREFIX_TO_KIND.iter() {
17 if *k == self.kind() && self.text().starts_with(prefix) {
18 return prefix;
19 }
20 }
21 unreachable!()
17 } 22 }
18} 23}
19 24
@@ -70,15 +75,6 @@ fn kind_by_prefix(text: &str) -> CommentKind {
70 panic!("bad comment text: {:?}", text) 75 panic!("bad comment text: {:?}", text)
71} 76}
72 77
73fn prefix_by_kind(kind: CommentKind) -> &'static str {
74 for (prefix, k) in COMMENT_PREFIX_TO_KIND.iter() {
75 if *k == kind {
76 return prefix;
77 }
78 }
79 unreachable!()
80}
81
82impl Whitespace { 78impl Whitespace {
83 pub fn spans_multiple_lines(&self) -> bool { 79 pub fn spans_multiple_lines(&self) -> bool {
84 let text = self.text(); 80 let text = self.text();