diff --git a/benches/powerset.rs b/benches/powerset.rs
index 018333d31..7d7fc17fe 100644
--- a/benches/powerset.rs
+++ b/benches/powerset.rs
@@ -8,7 +8,7 @@ const fn calc_iters(n: usize) -> usize {
}
fn powerset_n(c: &mut Criterion, n: usize) {
- let id = format!("powerset {}", n);
+ let id = format!("powerset {n}");
c.bench_function(id.as_str(), move |b| {
b.iter(|| {
for _ in 0..calc_iters(n) {
@@ -21,7 +21,7 @@ fn powerset_n(c: &mut Criterion, n: usize) {
}
fn powerset_n_fold(c: &mut Criterion, n: usize) {
- let id = format!("powerset {} fold", n);
+ let id = format!("powerset {n} fold");
c.bench_function(id.as_str(), move |b| {
b.iter(|| {
for _ in 0..calc_iters(n) {
diff --git a/examples/iris.rs b/examples/iris.rs
index 63f9c4832..fe783b9b7 100644
--- a/examples/iris.rs
+++ b/examples/iris.rs
@@ -65,7 +65,7 @@ fn main() {
});
let mut irises = match irises {
Err(e) => {
- println!("Error parsing: {:?}", e);
+ println!("Error parsing: {e:?}");
std::process::exit(1);
}
Ok(data) => data,
@@ -101,7 +101,7 @@ fn main() {
// using Itertools::tuple_combinations
for (a, b) in (0..4).tuple_combinations() {
- println!("Column {} vs {}:", a, b);
+ println!("Column {a} vs {b}:");
// Clear plot
//
diff --git a/src/either_or_both.rs b/src/either_or_both.rs
index b7a7fc141..03a312e90 100644
--- a/src/either_or_both.rs
+++ b/src/either_or_both.rs
@@ -421,7 +421,7 @@ impl EitherOrBoth {
/// // Inserting a second value.
/// let mut either = Left("what's");
/// assert_eq!(*either.insert_right(9 + 10), 21 - 2);
- /// assert_eq!(either, Both("what's", 9+10));
+ /// assert_eq!(either, Both("what's", 9 + 10));
/// ```
pub fn insert_right(&mut self, val: B) -> &mut B {
match self {
diff --git a/src/free.rs b/src/free.rs
index 4c6820543..2051be8b6 100644
--- a/src/free.rs
+++ b/src/free.rs
@@ -119,7 +119,7 @@ where
/// for (a, b) in zip(&[1, 2, 3, 4, 5], &['a', 'b', 'c']) {
/// result.push((*a, *b));
/// }
-/// assert_eq!(result, vec![(1, 'a'),(2, 'b'),(3, 'c')]);
+/// assert_eq!(result, vec![(1, 'a'), (2, 'b'), (3, 'c')]);
/// ```
#[deprecated(
note = "Use [std::iter::zip](https://doc.rust-lang.org/std/iter/fn.zip.html) instead",
@@ -141,7 +141,7 @@ where
/// ```
/// use itertools::chain;
///
-/// let mut result:Vec = Vec::new();
+/// let mut result: Vec = Vec::new();
///
/// for element in chain(&[1, 2, 3], &[4]) {
/// result.push(*element);
@@ -284,8 +284,8 @@ where
/// [`IntoIterator`] enabled version of [`Itertools::sorted`].
///
/// ```
-/// use itertools::sorted;
/// use itertools::assert_equal;
+/// use itertools::sorted;
///
/// assert_equal(sorted("rust".chars()), "rstu".chars());
/// ```
@@ -304,8 +304,8 @@ where
/// [`IntoIterator`] enabled version of [`Itertools::sorted_unstable`].
///
/// ```
-/// use itertools::sorted_unstable;
/// use itertools::assert_equal;
+/// use itertools::sorted_unstable;
///
/// assert_equal(sorted_unstable("rust".chars()), "rstu".chars());
/// ```
diff --git a/src/grouping_map.rs b/src/grouping_map.rs
index 86cb55dc0..725e2592a 100644
--- a/src/grouping_map.rs
+++ b/src/grouping_map.rs
@@ -139,7 +139,7 @@ where
///
/// #[derive(Debug, Default)]
/// struct Accumulator {
- /// acc: usize,
+ /// acc: usize,
/// }
///
/// let lookup = (1..=7)
@@ -458,7 +458,7 @@ where
///
/// ```
/// use itertools::Itertools;
- /// use itertools::MinMaxResult::{OneElement, MinMax};
+ /// use itertools::MinMaxResult::{MinMax, OneElement};
///
/// let lookup = vec![1, 3, 4, 5, 7, 9, 12].into_iter()
/// .into_grouping_map_by(|&n| n % 3)
@@ -488,7 +488,7 @@ where
///
/// ```
/// use itertools::Itertools;
- /// use itertools::MinMaxResult::{OneElement, MinMax};
+ /// use itertools::MinMaxResult::{MinMax, OneElement};
///
/// let lookup = vec![1, 3, 4, 5, 7, 9, 12].into_iter()
/// .into_grouping_map_by(|&n| n % 3)
@@ -539,7 +539,7 @@ where
///
/// ```
/// use itertools::Itertools;
- /// use itertools::MinMaxResult::{OneElement, MinMax};
+ /// use itertools::MinMaxResult::{MinMax, OneElement};
///
/// let lookup = vec![1, 3, 4, 5, 7, 9, 12].into_iter()
/// .into_grouping_map_by(|&n| n % 3)
diff --git a/src/lib.rs b/src/lib.rs
index fb582b988..375e5c99a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -384,8 +384,8 @@ macro_rules! izip {
///
/// Empty invocations of `chain!` expand to an invocation of [`std::iter::empty`]:
/// ```
-/// use std::iter;
/// use itertools::chain;
+/// use std::iter;
///
/// let _: iter::Empty<()> = chain!();
/// let _: iter::Empty = chain!();
@@ -393,8 +393,8 @@ macro_rules! izip {
///
/// Invocations of `chain!` with one argument expand to [`arg.into_iter()`](IntoIterator):
/// ```
-/// use std::ops::Range;
/// use itertools::chain;
+/// use std::ops::Range;
/// let _: as IntoIterator>::IntoIter = chain!(2..6,); // trailing comma optional!
/// let _: <&[_] as IntoIterator>::IntoIter = chain!(&[2, 3, 4]);
/// ```
@@ -402,11 +402,11 @@ macro_rules! izip {
/// Invocations of `chain!` with multiple arguments [`.into_iter()`](IntoIterator) each
/// argument, and then [`chain`] them together:
/// ```
-/// use std::{iter::*, slice};
/// use itertools::{assert_equal, chain};
+/// use std::{iter::*, slice};
///
/// // e.g., this:
-/// let with_macro: Chain, Take>>, slice::Iter<_>> =
+/// let with_macro: Chain, Take>>, slice::Iter<_>> =
/// chain![once(&0), repeat(&1).take(2), &[2, 3, 5],];
///
/// // ...is equivalent to this:
@@ -653,7 +653,6 @@ pub trait Itertools: Iterator {
///
/// itertools::assert_equal(pit, vec![(0, 1), (2, 3)]);
/// ```
- ///
fn batching(self, f: F) -> Batching
where
F: FnMut(&mut Self) -> Option,
@@ -1100,8 +1099,8 @@ pub trait Itertools: Iterator {
/// and remove both `i` and `j` from their respective source iterators
///
/// ```
+ /// use itertools::EitherOrBoth::{Both, Left, Right};
/// use itertools::Itertools;
- /// use itertools::EitherOrBoth::{Left, Right, Both};
///
/// let a = vec![0, 2, 4, 6, 1].into_iter();
/// let b = (0..10).step_by(3);
@@ -1129,8 +1128,8 @@ pub trait Itertools: Iterator {
/// "less" than the second argument.
///
/// ```
- /// use itertools::Itertools;
/// use itertools::Either::{Left, Right};
+ /// use itertools::Itertools;
///
/// let a = vec![0, 2, 4, 6, 1].into_iter();
/// let b = (0..10).step_by(3);
@@ -1543,7 +1542,6 @@ pub trait Itertools: Iterator {
/// .collect::();
/// assert_eq!(decimals, "0123456789");
/// assert_eq!(hexadecimals.next(), Some('a'));
- ///
/// ```
fn take_while_ref(&mut self, accept: F) -> TakeWhileRef
where
@@ -1633,8 +1631,8 @@ pub trait Itertools: Iterator {
/// // List all hexadecimal digits
/// itertools::assert_equal(
/// (0..).map(|i| std::char::from_digit(i, 16)).while_some(),
- /// "0123456789abcdef".chars());
- ///
+ /// "0123456789abcdef".chars(),
+ /// );
/// ```
fn while_some(self) -> WhileSome
where
@@ -1930,13 +1928,13 @@ pub trait Itertools: Iterator {
/// ```
/// use itertools::Itertools;
///
- /// let it = (0..5).pad_using(10, |i| 2*i);
+ /// let it = (0..5).pad_using(10, |i| 2 * i);
/// itertools::assert_equal(it, vec![0, 1, 2, 3, 4, 10, 12, 14, 16, 18]);
///
- /// let it = (0..10).pad_using(5, |i| 2*i);
+ /// let it = (0..10).pad_using(5, |i| 2 * i);
/// itertools::assert_equal(it, vec![0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
///
- /// let it = (0..5).pad_using(10, |i| 2*i).rev();
+ /// let it = (0..5).pad_using(10, |i| 2 * i).rev();
/// itertools::assert_equal(it, vec![18, 16, 14, 12, 10, 4, 3, 2, 1, 0]);
/// ```
fn pad_using(self, min: usize, f: F) -> PadUsing
@@ -2243,7 +2241,7 @@ pub trait Itertools: Iterator {
/// assert!(data[3..5].iter().all_equal());
/// assert!(data[5..8].iter().all_equal());
///
- /// let data : Option = None;
+ /// let data: Option = None;
/// assert!(data.into_iter().all_equal());
/// ```
fn all_equal(&mut self) -> bool
@@ -2271,7 +2269,7 @@ pub trait Itertools: Iterator {
/// assert_eq!(data[3..5].iter().all_equal_value(), Ok(&2));
/// assert_eq!(data[5..8].iter().all_equal_value(), Ok(&3));
///
- /// let data : Option = None;
+ /// let data: Option = None;
/// assert_eq!(data.into_iter().all_equal_value(), Err(None));
/// ```
#[allow(clippy::type_complexity)]
@@ -2301,7 +2299,7 @@ pub trait Itertools: Iterator {
/// assert!(data[0..4].iter().all_unique());
/// assert!(data[1..6].iter().all_unique());
///
- /// let data : Option = None;
+ /// let data: Option = None;
/// assert!(data.into_iter().all_unique());
/// ```
#[cfg(feature = "use_std")]
@@ -2403,8 +2401,8 @@ pub trait Itertools: Iterator {
/// # Example
///
/// ```
- /// use std::{fs, io};
/// use itertools::Itertools;
+ /// use std::{fs, io};
///
/// fn process_dir_entries(entries: &[fs::DirEntry]) {
/// // ...
@@ -2476,10 +2474,10 @@ pub trait Itertools: Iterator {
// estimate lower bound of capacity needed
let (lower, _) = self.size_hint();
let mut result = String::with_capacity(sep.len() * lower);
- write!(&mut result, "{}", first_elt).unwrap();
+ write!(&mut result, "{first_elt}").unwrap();
self.for_each(|elt| {
result.push_str(sep);
- write!(&mut result, "{}", elt).unwrap();
+ write!(&mut result, "{elt}").unwrap();
});
result
}
@@ -2576,8 +2574,8 @@ pub trait Itertools: Iterator {
/// this effectively results in *((0 + 1) + 2) + 3*
///
/// ```
- /// use std::ops::Add;
/// use itertools::Itertools;
+ /// use std::ops::Add;
///
/// let values = [1, 2, -2, -1, 2, 1];
/// assert_eq!(
@@ -2616,8 +2614,8 @@ pub trait Itertools: Iterator {
/// This is the `Option` equivalent to [`fold_ok`](Itertools::fold_ok).
///
/// ```
- /// use std::ops::Add;
/// use itertools::Itertools;
+ /// use std::ops::Add;
///
/// let mut values = vec![Some(1), Some(2), Some(-2)].into_iter();
/// assert_eq!(values.fold_options(5, Add::add), Some(5 + 1 + 2 - 2));
@@ -2832,8 +2830,8 @@ pub trait Itertools: Iterator {
/// early exit via short-circuiting.
///
/// ```
- /// use itertools::Itertools;
/// use itertools::FoldWhile::{Continue, Done};
+ /// use itertools::Itertools;
///
/// let numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
///
@@ -3662,7 +3660,7 @@ pub trait Itertools: Iterator {
/// have a distinct type.
///
/// ```
- /// use itertools::{Itertools, Either};
+ /// use itertools::{Either, Itertools};
///
/// let successes_and_failures = vec![Ok(1), Err(false), Err(true), Ok(2)];
///
@@ -3761,17 +3759,17 @@ pub trait Itertools: Iterator {
/// let lookup: HashMap> =
/// data.clone().into_iter().into_group_map_by(|a| a.0);
///
- /// assert_eq!(lookup[&0], vec![(0,10), (0,20)]);
+ /// assert_eq!(lookup[&0], vec![(0, 10), (0, 20)]);
/// assert_eq!(lookup.get(&1), None);
- /// assert_eq!(lookup[&2], vec![(2,12), (2,42)]);
- /// assert_eq!(lookup[&3], vec![(3,13), (3,33)]);
+ /// assert_eq!(lookup[&2], vec![(2, 12), (2, 42)]);
+ /// assert_eq!(lookup[&3], vec![(3, 13), (3, 33)]);
///
/// assert_eq!(
/// data.into_iter()
/// .into_group_map_by(|x| x.0)
/// .into_iter()
- /// .map(|(key, values)| (key, values.into_iter().fold(0,|acc, (_,v)| acc + v )))
- /// .collect::>()[&0],
+ /// .map(|(key, values)| (key, values.into_iter().fold(0, |acc, (_, v)| acc + v)))
+ /// .collect::>()[&0],
/// 30,
/// );
/// ```
@@ -4033,7 +4031,7 @@ pub trait Itertools: Iterator {
///
/// ```
/// use itertools::Itertools;
- /// use itertools::MinMaxResult::{NoElements, OneElement, MinMax};
+ /// use itertools::MinMaxResult::{MinMax, NoElements, OneElement};
///
/// let a: [i32; 0] = [];
/// assert_eq!(a.iter().minmax(), NoElements);
@@ -4302,7 +4300,7 @@ pub trait Itertools: Iterator {
///
/// ```
/// use itertools::Itertools;
- /// use itertools::MinMaxResult::{NoElements, OneElement, MinMax};
+ /// use itertools::MinMaxResult::{MinMax, NoElements, OneElement};
///
/// let a: [i32; 0] = [];
/// assert_eq!(a.iter().position_minmax(), NoElements);
@@ -4347,7 +4345,7 @@ pub trait Itertools: Iterator {
///
/// ```
/// use itertools::Itertools;
- /// use itertools::MinMaxResult::{NoElements, OneElement, MinMax};
+ /// use itertools::MinMaxResult::{MinMax, NoElements, OneElement};
///
/// let a: [i32; 0] = [];
/// assert_eq!(a.iter().position_minmax_by_key(|x| x.abs()), NoElements);
@@ -4392,7 +4390,7 @@ pub trait Itertools: Iterator {
///
/// ```
/// use itertools::Itertools;
- /// use itertools::MinMaxResult::{NoElements, OneElement, MinMax};
+ /// use itertools::MinMaxResult::{MinMax, NoElements, OneElement};
///
/// let a: [i32; 0] = [];
/// assert_eq!(a.iter().position_minmax_by(|x, y| x.cmp(y)), NoElements);
@@ -4541,9 +4539,9 @@ pub trait Itertools: Iterator {
/// ```
/// # use itertools::Itertools;
/// struct Character {
- /// first_name: &'static str,
+ /// first_name: &'static str,
/// # #[allow(dead_code)]
- /// last_name: &'static str,
+ /// last_name: &'static str,
/// }
///
/// let characters =
diff --git a/src/minmax.rs b/src/minmax.rs
index 5c9674e01..b68efffd4 100644
--- a/src/minmax.rs
+++ b/src/minmax.rs
@@ -24,7 +24,7 @@ impl MinMaxResult {
/// # Examples
///
/// ```
- /// use itertools::MinMaxResult::{self, NoElements, OneElement, MinMax};
+ /// use itertools::MinMaxResult::{self, MinMax, NoElements, OneElement};
///
/// let r: MinMaxResult = NoElements;
/// assert_eq!(r.into_option(), None);
diff --git a/src/size_hint.rs b/src/size_hint.rs
index 6cfead7f2..dbaaa77ed 100644
--- a/src/size_hint.rs
+++ b/src/size_hint.rs
@@ -1,5 +1,4 @@
//! Arithmetic on `Iterator.size_hint()` values.
-//!
use std::cmp;
diff --git a/tests/quick.rs b/tests/quick.rs
index 0af73778a..3ab5b8fc4 100644
--- a/tests/quick.rs
+++ b/tests/quick.rs
@@ -275,8 +275,7 @@ where
let actual_count = total_actual_count - i;
if actual_count != returned_count {
println!(
- "Total iterations: {} True count: {} returned count: {}",
- i, actual_count, returned_count
+ "Total iterations: {i} True count: {actual_count} returned count: {returned_count}"
);
return false;
diff --git a/tests/test_std.rs b/tests/test_std.rs
index c0ee373aa..0dadac154 100644
--- a/tests/test_std.rs
+++ b/tests/test_std.rs
@@ -1531,7 +1531,7 @@ fn tree_reduce() {
Some(s.to_string())
};
let num_strings = (0..i).map(|x| x.to_string());
- let actual = num_strings.tree_reduce(|a, b| format!("{} {} x", a, b));
+ let actual = num_strings.tree_reduce(|a, b| format!("{a} {b} x"));
assert_eq!(actual, expected);
}
}