11#![ warn( missing_docs, clippy:: default_numeric_fallback) ]
22#![ crate_name = "itertools" ]
33#![ cfg_attr( not( feature = "use_std" ) , no_std) ]
4+ #![ doc( test( attr( deny( warnings) , allow( deprecated, unstable_name_collisions) ) ) ) ]
45
56//! Extra iterator adaptors, functions and macros.
67//!
78//! To extend [`Iterator`] with methods in this crate, import
89//! the [`Itertools`] trait:
910//!
1011//! ```
12+ //! # #[allow(unused_imports)]
1113//! use itertools::Itertools;
1214//! ```
1315//!
2931//!
3032//! for elt in interleave(&[1, 2, 3], &[2, 3, 4]) {
3133//! /* loop body */
34+ //! # let _ = elt;
3235//! }
3336//! ```
3437//!
@@ -248,6 +251,7 @@ mod ziptuple;
248251/// // from (0, 0, 0), (0, 0, 1), .., (0, 1, 0), (0, 1, 1), .. etc until (3, 3, 3)
249252/// for (i, j, k) in iproduct!(0..4, 0..4, 0..4) {
250253/// // ..
254+ /// # let _ = (i, j, k);
251255/// }
252256/// # }
253257/// ```
@@ -375,16 +379,16 @@ macro_rules! izip {
375379///
376380/// Invocations of `chain!` with one argument expand to [`arg.into_iter()`](IntoIterator):
377381/// ```
378- /// use std::{ ops::Range, slice} ;
382+ /// use std::ops::Range;
379383/// use itertools::chain;
380- /// let _: <Range<_> as IntoIterator>::IntoIter = chain!(( 2..6) ,); // trailing comma optional!
384+ /// let _: <Range<_> as IntoIterator>::IntoIter = chain!(2..6,); // trailing comma optional!
381385/// let _: <&[_] as IntoIterator>::IntoIter = chain!(&[2, 3, 4]);
382386/// ```
383387///
384388/// Invocations of `chain!` with multiple arguments [`.into_iter()`](IntoIterator) each
385389/// argument, and then [`chain`] them together:
386390/// ```
387- /// use std::{iter::*, ops::Range, slice};
391+ /// use std::{iter::*, slice};
388392/// use itertools::{assert_equal, chain};
389393///
390394/// // e.g., this:
@@ -1902,7 +1906,7 @@ pub trait Itertools: Iterator {
19021906 /// use itertools::Itertools;
19031907 ///
19041908 /// let input = vec![vec![1], vec![3, 2, 1]];
1905- /// let it = input.into_iter().update(|mut v| v.push(0));
1909+ /// let it = input.into_iter().update(|v| v.push(0));
19061910 /// itertools::assert_equal(it, vec![vec![1, 0], vec![3, 2, 1, 0]]);
19071911 /// ```
19081912 fn update < F > ( self , updater : F ) -> Update < Self , F >
@@ -2162,7 +2166,7 @@ pub trait Itertools: Iterator {
21622166 /// ```
21632167 /// use itertools::Itertools;
21642168 ///
2165- /// let mut iter = "αβγ".chars().dropping(2);
2169+ /// let iter = "αβγ".chars().dropping(2);
21662170 /// itertools::assert_equal(iter, "γ".chars());
21672171 /// ```
21682172 ///
@@ -2246,14 +2250,17 @@ pub trait Itertools: Iterator {
22462250 ///
22472251 /// fn process_dir_entries(entries: &[fs::DirEntry]) {
22482252 /// // ...
2253+ /// # let _ = entries;
22492254 /// }
22502255 ///
2251- /// fn do_stuff() -> std:: io::Result<()> {
2256+ /// fn do_stuff() -> io::Result<()> {
22522257 /// let entries: Vec<_> = fs::read_dir(".")?.try_collect()?;
22532258 /// process_dir_entries(&entries);
22542259 ///
22552260 /// Ok(())
22562261 /// }
2262+ ///
2263+ /// # let _ = do_stuff;
22572264 /// ```
22582265 fn try_collect < T , U , E > ( self ) -> Result < U , E >
22592266 where
@@ -2404,6 +2411,7 @@ pub trait Itertools: Iterator {
24042411 /// accum = f(accum, 1);
24052412 /// accum = f(accum, 2);
24062413 /// accum = f(accum, 3);
2414+ /// # let _ = accum;
24072415 /// ```
24082416 ///
24092417 /// With a `start` value of 0 and an addition as folding function,
@@ -2554,16 +2562,16 @@ pub trait Itertools: Iterator {
25542562 /// assert_eq!((1..8).map(|x| x.to_string()).tree_reduce(f),
25552563 /// Some(String::from("f(f(f(1, 2), f(3, 4)), f(f(5, 6), 7))")));
25562564 ///
2557- /// // Like fold1 , an empty iterator produces None
2565+ /// // Like reduce , an empty iterator produces None
25582566 /// assert_eq!((0..0).tree_reduce(|x, y| x * y), None);
25592567 ///
2560- /// // tree_reduce matches fold1 for associative operations...
2568+ /// // tree_reduce matches reduce for associative operations...
25612569 /// assert_eq!((0..10).tree_reduce(|x, y| x + y),
2562- /// (0..10).fold1 (|x, y| x + y));
2570+ /// (0..10).reduce (|x, y| x + y));
25632571 ///
25642572 /// // ...but not for non-associative ones
25652573 /// assert_ne!((0..10).tree_reduce(|x, y| x - y),
2566- /// (0..10).fold1 (|x, y| x - y));
2574+ /// (0..10).reduce (|x, y| x - y));
25672575 ///
25682576 /// let mut total_len_reduce = 0;
25692577 /// let reduce_res = (1..100).map(|x| x.to_string())
@@ -4350,7 +4358,7 @@ pub trait Itertools: Iterator {
43504358 /// # Examples
43514359 /// ```
43524360 /// # use itertools::Itertools;
4353- /// let counts = [1, 1, 1, 3, 3, 5].into_iter ().counts();
4361+ /// let counts = [1, 1, 1, 3, 3, 5].iter ().counts();
43544362 /// assert_eq!(counts[&1], 3);
43554363 /// assert_eq!(counts[&3], 2);
43564364 /// assert_eq!(counts[&5], 1);
@@ -4376,6 +4384,7 @@ pub trait Itertools: Iterator {
43764384 /// # use itertools::Itertools;
43774385 /// struct Character {
43784386 /// first_name: &'static str,
4387+ /// # #[allow(dead_code)]
43794388 /// last_name: &'static str,
43804389 /// }
43814390 ///
0 commit comments