Skip to content

Commit f8f4bc0

Browse files
committed
misc: Apply clippy suggestions
1 parent 93120ec commit f8f4bc0

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

src/colorize.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ where
4444
);
4545
continue;
4646
}
47-
subcolorize(Some(&subkey), subvalue, output, color, subindent);
47+
subcolorize(Some(subkey), subvalue, output, color, subindent);
4848
}
4949
output(color, &format!("{}}}", indent));
5050
}

src/diff.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,7 @@ impl JsonDiff {
4343
/// returns it as a formatted string.
4444
pub fn diff_string(json1: &Value, json2: &Value, keys_only: bool) -> Option<String> {
4545
let Self { score: _, diff } = Self::diff(json1, json2, keys_only);
46-
if let Some(value) = diff {
47-
Some(colorize_to_array(&value).join("\n") + "\n")
48-
} else {
49-
None
50-
}
46+
diff.map(|value| colorize_to_array(&value).join("\n") + "\n")
5147
}
5248

5349
fn object_diff(obj1: &Map<String, Value>, obj2: &Map<String, Value>, keys_only: bool) -> Self {
@@ -76,11 +72,11 @@ impl JsonDiff {
7672
let Self {
7773
score: subscore,
7874
diff: change,
79-
} = Self::diff_with_score(&value1, &value2, keys_only);
75+
} = Self::diff_with_score(value1, value2, keys_only);
8076
if let Some(change) = change {
8177
result.insert(key.clone(), change);
8278
}
83-
score += ((subscore / 5.).max(-10.)).min(20.);
79+
score += (subscore / 5.).clamp(-10., 20.);
8480
}
8581
}
8682

@@ -117,7 +113,7 @@ impl JsonDiff {
117113

118114
for (match_index, (key, candidate)) in fuzzy_originals.into_iter().enumerate() {
119115
if key != "__next" {
120-
let index_distance = (match_index as isize - index as isize).abs() as usize;
116+
let index_distance = (match_index as isize - index as isize).unsigned_abs();
121117
if Self::check_type(item, candidate) {
122118
let Self { score, diff: _ } = Self::diff(item, candidate, false);
123119
if best_match.as_ref().map_or(true, |v| score > v.score)

0 commit comments

Comments
 (0)