Skip to content

Commit df00c92

Browse files
Simplifications from clippy
`clippy::uninlined_format_args` and 2 more.
1 parent ca8a8fb commit df00c92

File tree

7 files changed

+14
-23
lines changed

7 files changed

+14
-23
lines changed

benches/powerset.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const fn calc_iters(n: usize) -> usize {
88
}
99

1010
fn powerset_n(c: &mut Criterion, n: usize) {
11-
let id = format!("powerset {}", n);
11+
let id = format!("powerset {n}");
1212
c.bench_function(id.as_str(), move |b| {
1313
b.iter(|| {
1414
for _ in 0..calc_iters(n) {
@@ -21,7 +21,7 @@ fn powerset_n(c: &mut Criterion, n: usize) {
2121
}
2222

2323
fn powerset_n_fold(c: &mut Criterion, n: usize) {
24-
let id = format!("powerset {} fold", n);
24+
let id = format!("powerset {n} fold");
2525
c.bench_function(id.as_str(), move |b| {
2626
b.iter(|| {
2727
for _ in 0..calc_iters(n) {

examples/iris.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ fn main() {
6565
});
6666
let mut irises = match irises {
6767
Err(e) => {
68-
println!("Error parsing: {:?}", e);
68+
println!("Error parsing: {e:?}");
6969
std::process::exit(1);
7070
}
7171
Ok(data) => data,
@@ -101,7 +101,7 @@ fn main() {
101101

102102
// using Itertools::tuple_combinations
103103
for (a, b) in (0..4).tuple_combinations() {
104-
println!("Column {} vs {}:", a, b);
104+
println!("Column {a} vs {b}:");
105105

106106
// Clear plot
107107
//

src/lib.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -2320,10 +2320,10 @@ pub trait Itertools: Iterator {
23202320
// estimate lower bound of capacity needed
23212321
let (lower, _) = self.size_hint();
23222322
let mut result = String::with_capacity(sep.len() * lower);
2323-
write!(&mut result, "{}", first_elt).unwrap();
2323+
write!(&mut result, "{first_elt}").unwrap();
23242324
self.for_each(|elt| {
23252325
result.push_str(sep);
2326-
write!(&mut result, "{}", elt).unwrap();
2326+
write!(&mut result, "{elt}").unwrap();
23272327
});
23282328
result
23292329
}
@@ -4522,13 +4522,7 @@ where
45224522
(Some(a), Some(b)) => a == b,
45234523
_ => false,
45244524
};
4525-
assert!(
4526-
equal,
4527-
"Failed assertion {a:?} == {b:?} for iteration {i}",
4528-
i = i,
4529-
a = a,
4530-
b = b
4531-
);
4525+
assert!(equal, "Failed assertion {a:?} == {b:?} for iteration {i}");
45324526
i += 1;
45334527
}
45344528
}

src/process_results_impl.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ where
6262

6363
impl<'a, I, T, E> DoubleEndedIterator for ProcessResults<'a, I, E>
6464
where
65-
I: Iterator<Item = Result<T, E>>,
66-
I: DoubleEndedIterator,
65+
I: DoubleEndedIterator<Item = Result<T, E>>,
6766
{
6867
fn next_back(&mut self) -> Option<Self::Item> {
6968
let item = self.iter.next_back();

src/repeatn.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ where
3434
fn next(&mut self) -> Option<Self::Item> {
3535
if self.n > 1 {
3636
self.n -= 1;
37-
self.elt.as_ref().cloned()
37+
self.elt.clone()
3838
} else {
3939
self.n = 0;
4040
self.elt.take()

tests/quick.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ where
275275
let actual_count = total_actual_count - i;
276276
if actual_count != returned_count {
277277
println!(
278-
"Total iterations: {} True count: {} returned count: {}",
279-
i, actual_count, returned_count
278+
"Total iterations: {i} True count: {actual_count} returned count: {returned_count}"
280279
);
281280

282281
return false;
@@ -676,7 +675,7 @@ quickcheck! {
676675
assert_eq!(perm.len(), k);
677676

678677
let all_items_valid = perm.iter().all(|p| vals.contains(p));
679-
assert!(all_items_valid, "perm contains value not from input: {:?}", perm);
678+
assert!(all_items_valid, "perm contains value not from input: {perm:?}");
680679

681680
// Check that all perm items are distinct
682681
let distinct_len = {
@@ -686,7 +685,7 @@ quickcheck! {
686685
assert_eq!(perm.len(), distinct_len);
687686

688687
// Check that the perm is new
689-
assert!(actual.insert(perm.clone()), "perm already encountered: {:?}", perm);
688+
assert!(actual.insert(perm.clone()), "perm already encountered: {perm:?}");
690689
}
691690
}
692691

@@ -712,8 +711,7 @@ quickcheck! {
712711
for next_perm in perms {
713712
assert!(
714713
next_perm > curr_perm,
715-
"next perm isn't greater-than current; next_perm={:?} curr_perm={:?} n={}",
716-
next_perm, curr_perm, n
714+
"next perm isn't greater-than current; next_perm={next_perm:?} curr_perm={curr_perm:?} n={n}"
717715
);
718716

719717
curr_perm = next_perm;

tests/test_std.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1505,7 +1505,7 @@ fn tree_reduce() {
15051505
Some(s.to_string())
15061506
};
15071507
let num_strings = (0..i).map(|x| x.to_string());
1508-
let actual = num_strings.tree_reduce(|a, b| format!("{} {} x", a, b));
1508+
let actual = num_strings.tree_reduce(|a, b| format!("{a} {b} x"));
15091509
assert_eq!(actual, expected);
15101510
}
15111511
}

0 commit comments

Comments
 (0)