Skip to content

Commit e0e633e

Browse files
authored
Use matches!() macro to improve readability (rust-lang#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()
1 parent e9dfb6f commit e0e633e

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

src/comment.rs

+12-14
Original file line numberDiff line numberDiff line change
@@ -58,25 +58,23 @@ fn custom_opener(s: &str) -> &str {
5858
}
5959

6060
impl<'a> CommentStyle<'a> {
61-
/// Returns `true` if the commenting style covers a line only.
61+
/// Returns `true` if the commenting style cannot span multiple lines.
6262
pub(crate) fn is_line_comment(&self) -> bool {
63-
match *self {
63+
matches!(
64+
self,
6465
CommentStyle::DoubleSlash
65-
| CommentStyle::TripleSlash
66-
| CommentStyle::Doc
67-
| CommentStyle::Custom(_) => true,
68-
_ => false,
69-
}
66+
| CommentStyle::TripleSlash
67+
| CommentStyle::Doc
68+
| CommentStyle::Custom(_)
69+
)
7070
}
7171

72-
/// Returns `true` if the commenting style can span over multiple lines.
72+
/// Returns `true` if the commenting style can span multiple lines.
7373
pub(crate) fn is_block_comment(&self) -> bool {
74-
match *self {
75-
CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation => {
76-
true
77-
}
78-
_ => false,
79-
}
74+
matches!(
75+
self,
76+
CommentStyle::SingleBullet | CommentStyle::DoubleBullet | CommentStyle::Exclamation
77+
)
8078
}
8179

8280
/// Returns `true` if the commenting style is for documentation.

0 commit comments

Comments
 (0)