diff --git a/src/hunks.rs b/src/hunks.rs index 1a769cecc..725ac7662 100644 --- a/src/hunks.rs +++ b/src/hunks.rs @@ -683,7 +683,7 @@ pub fn matched_lines_for_hunk( end_i = matched_lines.len(); } - matched_lines[start_i..end_i].iter().copied().collect() + matched_lines[start_i..end_i].to_vec() } #[cfg(test)] diff --git a/src/inline.rs b/src/inline.rs index b7e602690..c512928b5 100644 --- a/src/inline.rs +++ b/src/inline.rs @@ -73,7 +73,7 @@ pub fn print( if let Some(lhs_line) = lhs_line { println!( "{} {}", - format_line_num(*lhs_line).red().bold().to_string(), + format_line_num(*lhs_line).red().bold(), lhs_lines[lhs_line.0] ); } else { @@ -84,7 +84,7 @@ pub fn print( if let Some(rhs_line) = rhs_line { println!( " {}{}", - format_line_num(*rhs_line).green().bold().to_string(), + format_line_num(*rhs_line).green().bold(), rhs_lines[rhs_line.0] ); } else { diff --git a/src/main.rs b/src/main.rs index 045ff6590..34c9832a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -201,10 +201,10 @@ fn diff_file_content( // TODO: don't replace tab characters inside string literals. let lhs_src = String::from_utf8_lossy(lhs_bytes) .to_string() - .replace("\t", " "); + .replace('\t', " "); let rhs_src = String::from_utf8_lossy(rhs_bytes) .to_string() - .replace("\t", " "); + .replace('\t', " "); // TODO: take a Path directly instead. let path = Path::new(&display_path); diff --git a/src/style.rs b/src/style.rs index 9f7e5de76..a97f76d8d 100644 --- a/src/style.rs +++ b/src/style.rs @@ -240,39 +240,40 @@ pub fn color_positions( for pos in positions { let mut style = Style::new(); match pos.kind { - MatchKind::UnchangedToken { highlight, .. } => match highlight { - TokenKind::Atom(atom_kind) => match atom_kind { - AtomKind::String => { - style = if background.is_dark() { - style.bright_magenta() - } else { - style.magenta() - }; + MatchKind::UnchangedToken { highlight, .. } => { + if let TokenKind::Atom(atom_kind) = highlight { + match atom_kind { + AtomKind::String => { + style = if background.is_dark() { + style.bright_magenta() + } else { + style.magenta() + }; + } + AtomKind::Comment => { + style = style.italic(); + style = if background.is_dark() { + style.bright_blue() + } else { + style.blue() + }; + } + AtomKind::Keyword | AtomKind::Type => { + style = style.bold(); + } + _ => {} } - AtomKind::Comment => { - style = style.italic(); - style = if background.is_dark() { - style.bright_blue() - } else { - style.blue() - }; - } - AtomKind::Keyword | AtomKind::Type => { - style = style.bold(); - } - _ => {} - }, - _ => {} - }, + } + } MatchKind::Novel { highlight, .. } => { style = novel_style(style, is_lhs, background); - match highlight { + if matches!( + highlight, TokenKind::Delimiter - | TokenKind::Atom(AtomKind::Keyword) - | TokenKind::Atom(AtomKind::Type) => { - style = style.bold(); - } - _ => {} + | TokenKind::Atom(AtomKind::Keyword) + | TokenKind::Atom(AtomKind::Type) + ) { + style = style.bold(); } if matches!(highlight, TokenKind::Atom(AtomKind::Comment)) { style = style.italic();