Skip to content

Commit ac396c3

Browse files
authored
all: fix clippy complaints (#2038)
Fix Clippy complaints from running `cargo clippy` and `cargo test`.
1 parent c22adce commit ac396c3

File tree

5 files changed

+11
-9
lines changed

5 files changed

+11
-9
lines changed

src/ansi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub fn truncate_str<'a>(s: &'a str, display_width: usize, tail: &str) -> Cow<'a,
100100
/// calculating the width. If a double-width ("fullwidth") grapheme has to be cut, it is omitted and
101101
/// the resulting string is *shorter* than `display_width`. But this way the result is always a
102102
/// prefix of the input `s`.
103-
pub fn truncate_str_short(s: &str, display_width: usize) -> Cow<str> {
103+
pub fn truncate_str_short(s: &str, display_width: usize) -> Cow<'_, str> {
104104
truncate_str_impl(s, display_width, "", None)
105105
}
106106

src/handlers/blame.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ pub fn format_blame_line_number(
307307
) -> (&str, String, &str) {
308308
let (format, empty) = match &format {
309309
BlameLineNumbers::PerBlock(format) => (format, is_repeat),
310-
BlameLineNumbers::Every(n, format) => (format, is_repeat && line_number % n != 0),
310+
BlameLineNumbers::Every(n, format) => (format, is_repeat && line_number.is_multiple_of(*n)),
311311
BlameLineNumbers::On(format) => (format, false),
312312
};
313313
let mut result = String::new();
@@ -546,7 +546,7 @@ mod tests {
546546
.collect()
547547
}
548548

549-
fn make_blame_line_with_time(timestamp: &str) -> BlameLine {
549+
fn make_blame_line_with_time(timestamp: &str) -> BlameLine<'_> {
550550
let time = chrono::DateTime::parse_from_rfc3339(timestamp).unwrap();
551551
BlameLine {
552552
commit: "",
@@ -557,14 +557,16 @@ mod tests {
557557
}
558558
}
559559

560-
fn make_format_data_with_placeholder(placeholder: &str) -> format::FormatStringPlaceholderData {
560+
fn make_format_data_with_placeholder(
561+
placeholder: &str,
562+
) -> format::FormatStringPlaceholderData<'_> {
561563
format::FormatStringPlaceholderData {
562564
placeholder: Some(Placeholder::Str(placeholder)),
563565
..Default::default()
564566
}
565567
}
566568

567-
fn make_blame_line_with_author(author: &str) -> BlameLine {
569+
fn make_blame_line_with_author(author: &str) -> BlameLine<'_> {
568570
BlameLine {
569571
commit: "",
570572
author,

src/handlers/grep.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -664,7 +664,7 @@ $
664664
.unwrap()
665665
}
666666

667-
pub fn parse_grep_line(line: &str) -> Option<GrepLine> {
667+
pub fn parse_grep_line(line: &str) -> Option<GrepLine<'_>> {
668668
if line.starts_with('{') {
669669
ripgrep_json::parse_line(line)
670670
} else {
@@ -682,7 +682,7 @@ pub fn parse_grep_line(line: &str) -> Option<GrepLine> {
682682
}
683683
}
684684

685-
pub fn parse_raw_grep_line(raw_line: &str) -> Option<GrepLine> {
685+
pub fn parse_raw_grep_line(raw_line: &str) -> Option<GrepLine<'_>> {
686686
// Early exit if we don't have an escape sequence
687687
if !raw_line.starts_with('\x1b') {
688688
return None;

src/handlers/ripgrep_json.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::handlers::grep;
88
use serde::Deserialize;
99
use serde_json::Value;
1010

11-
pub fn parse_line(line: &str) -> Option<grep::GrepLine> {
11+
pub fn parse_line(line: &str) -> Option<grep::GrepLine<'_>> {
1212
let ripgrep_line: Option<RipGrepLine> = serde_json::from_str(line).ok();
1313
match ripgrep_line {
1414
Some(ripgrep_line) => {

src/paint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ fn get_diff_style_sections<'a>(
777777
(diff_sections, line_alignment)
778778
}
779779

780-
fn painted_prefix(state: State, config: &config::Config) -> Option<ANSIString> {
780+
fn painted_prefix(state: State, config: &config::Config) -> Option<ANSIString<'_>> {
781781
use DiffType::*;
782782
use State::*;
783783
match (state, config.keep_plus_minus_markers) {

0 commit comments

Comments
 (0)