Fix more clippy warnings

html_output
Wilfred Hughes 2022-02-24 20:49:11 +07:00
parent 0905fb74c3
commit 75bca2bc57
4 changed files with 35 additions and 34 deletions

@ -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)]

@ -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 {

@ -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);

@ -240,8 +240,9 @@ 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 {
MatchKind::UnchangedToken { highlight, .. } => {
if let TokenKind::Atom(atom_kind) = highlight {
match atom_kind {
AtomKind::String => {
style = if background.is_dark() {
style.bright_magenta()
@ -261,19 +262,19 @@ pub fn color_positions(
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) => {
| TokenKind::Atom(AtomKind::Type)
) {
style = style.bold();
}
_ => {}
}
if matches!(highlight, TokenKind::Atom(AtomKind::Comment)) {
style = style.italic();
}