}
pub fn is_different_group(&self) -> bool {
- self.inner_as_ref().contains('\n') || self.pre_comment.is_some() || self
- .post_comment
- .as_ref()
- .map_or(false, |s| s.contains('\n'))
+ self.inner_as_ref().contains('\n')
+ || self.pre_comment.is_some()
+ || self
+ .post_comment
+ .as_ref()
+ .map_or(false, |s| s.contains('\n'))
}
pub fn is_multiline(&self) -> bool {
}
impl Separator {
- pub fn len(&self) -> usize {
- match *self {
+ pub fn len(self) -> usize {
+ match self {
// 2 = `, `
Separator::Comma => 2,
// 3 = ` | `
formatted_comment = rewrite_post_comment(&mut item_max_width)?;
comment_alignment = post_comment_alignment(item_max_width, inner_item.len());
}
- for _ in 0..(comment_alignment + 1) {
+ for _ in 0..=comment_alignment {
result.push(' ');
}
// An additional space for the missing trailing separator.
pub fn extract_pre_comment(pre_snippet: &str) -> (Option<String>, ListItemCommentStyle) {
let trimmed_pre_snippet = pre_snippet.trim();
+ let has_block_comment = trimmed_pre_snippet.ends_with("*/");
let has_single_line_comment = trimmed_pre_snippet.starts_with("//");
- let has_block_comment = trimmed_pre_snippet.starts_with("/*");
- if has_single_line_comment {
- (
- Some(trimmed_pre_snippet.to_owned()),
- ListItemCommentStyle::DifferentLine,
- )
- } else if has_block_comment {
+ if has_block_comment {
let comment_end = pre_snippet.chars().rev().position(|c| c == '/').unwrap();
if pre_snippet
.chars()
ListItemCommentStyle::SameLine,
)
}
+ } else if has_single_line_comment {
+ (
+ Some(trimmed_pre_snippet.to_owned()),
+ ListItemCommentStyle::DifferentLine,
+ )
} else {
(None, ListItemCommentStyle::None)
}