Use matches!() macro to improve readability (#5830)
* Use matches!() macro to improve readability 1. Use `matches!()` macro in `is_line_comment` and `is_block_comment` to improve readability. 2. Very sightly improve the wording of the doc comment for these two functions. * Update wording on doc comment on is_line_comment()
This commit is contained in:
parent
e9dfb6f217
commit
e0e633ef14
@ -58,25 +58,23 @@ fn custom_opener(s: &str) -> &str {
|
||||
}
|
||||
|
||||
impl<'a> CommentStyle<'a> {
|
||||
/// Returns `true` if the commenting style covers a line only.
|
||||
/// Returns `true` if the commenting style cannot span multiple lines.
|
||||
pub(crate) fn is_line_comment(&self) -> bool {
|
||||
match *self {
|
||||
matches!(
|
||||
self,
|
||||
CommentStyle::DoubleSlash
|
||||
| CommentStyle::TripleSlash
|
||||
| CommentStyle::Doc
|
||||
| CommentStyle::Custom(_) => true,
|
||||
_ => false,
|
||||
}
|
||||
| CommentStyle::TripleSlash
|
||||
| CommentStyle::Doc
|
||||
| CommentStyle::Custom(_)
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns `true` if the commenting style can span over multiple lines.
|
||||
/// Returns `true` if the commenting style can span multiple lines.
|
||||
pub(crate) fn is_block_comment(&self) -> bool {
|
||||
match *self {
|
||||
CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation => {
|
||||
true
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
matches!(
|
||||
self,
|
||||
CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation
|
||||
)
|
||||
}
|
||||
|
||||
/// Returns `true` if the commenting style is for documentation.
|
||||
|
Loading…
Reference in New Issue
Block a user