Add comment_str

This commit is contained in:
Richard Feldman 2022-10-30 07:17:10 -04:00
parent a574dff481
commit e0e25a48bf
No known key found for this signature in database
GPG key ID: F1F21AA5B1D9E43B

View file

@ -615,6 +615,14 @@ impl<'a> CommentOrNewline<'a> {
DocComment(comment_str) => format!("##{}", comment_str),
}
}
pub fn comment_str(&'a self) -> Option<&'a str> {
match self {
CommentOrNewline::LineComment(s) => Some(*s),
CommentOrNewline::DocComment(s) => Some(*s),
_ => None,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]