Fix comment prefix method for four slash comments

This commit is contained in:
adamrk 2020-04-28 21:13:37 +02:00
parent b6560e3ebb
commit 0bd7d81805

View file

@ -13,7 +13,12 @@ impl Comment {
} }
pub fn prefix(&self) -> &'static str { pub fn prefix(&self) -> &'static str {
prefix_by_kind(self.kind()) for (prefix, k) in COMMENT_PREFIX_TO_KIND.iter() {
if *k == self.kind() && self.text().starts_with(prefix) {
return prefix;
}
}
unreachable!()
} }
} }
@ -70,15 +75,6 @@ fn kind_by_prefix(text: &str) -> CommentKind {
panic!("bad comment text: {:?}", text) panic!("bad comment text: {:?}", text)
} }
fn prefix_by_kind(kind: CommentKind) -> &'static str {
for (prefix, k) in COMMENT_PREFIX_TO_KIND.iter() {
if *k == kind {
return prefix;
}
}
unreachable!()
}
impl Whitespace { impl Whitespace {
pub fn spans_multiple_lines(&self) -> bool { pub fn spans_multiple_lines(&self) -> bool {
let text = self.text(); let text = self.text();