1
1
#![ warn( missing_docs, clippy:: default_numeric_fallback) ]
2
2
#![ crate_name = "itertools" ]
3
3
#![ cfg_attr( not( feature = "use_std" ) , no_std) ]
4
+ #![ doc( test( attr( deny( warnings) , allow( deprecated, unstable_name_collisions) ) ) ) ]
4
5
5
6
//! Extra iterator adaptors, functions and macros.
6
7
//!
7
8
//! To extend [`Iterator`] with methods in this crate, import
8
9
//! the [`Itertools`] trait:
9
10
//!
10
11
//! ```
12
+ //! # #[allow(unused_imports)]
11
13
//! use itertools::Itertools;
12
14
//! ```
13
15
//!
29
31
//!
30
32
//! for elt in interleave(&[1, 2, 3], &[2, 3, 4]) {
31
33
//! /* loop body */
34
+ //! # let _ = elt;
32
35
//! }
33
36
//! ```
34
37
//!
@@ -248,6 +251,7 @@ mod ziptuple;
248
251
/// // from (0, 0, 0), (0, 0, 1), .., (0, 1, 0), (0, 1, 1), .. etc until (3, 3, 3)
249
252
/// for (i, j, k) in iproduct!(0..4, 0..4, 0..4) {
250
253
/// // ..
254
+ /// # let _ = (i, j, k);
251
255
/// }
252
256
/// # }
253
257
/// ```
@@ -375,16 +379,16 @@ macro_rules! izip {
375
379
///
376
380
/// Invocations of `chain!` with one argument expand to [`arg.into_iter()`](IntoIterator):
377
381
/// ```
378
- /// use std::{ ops::Range, slice} ;
382
+ /// use std::ops::Range;
379
383
/// 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!
381
385
/// let _: <&[_] as IntoIterator>::IntoIter = chain!(&[2, 3, 4]);
382
386
/// ```
383
387
///
384
388
/// Invocations of `chain!` with multiple arguments [`.into_iter()`](IntoIterator) each
385
389
/// argument, and then [`chain`] them together:
386
390
/// ```
387
- /// use std::{iter::*, ops::Range, slice};
391
+ /// use std::{iter::*, slice};
388
392
/// use itertools::{assert_equal, chain};
389
393
///
390
394
/// // e.g., this:
@@ -1902,7 +1906,7 @@ pub trait Itertools: Iterator {
1902
1906
/// use itertools::Itertools;
1903
1907
///
1904
1908
/// 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));
1906
1910
/// itertools::assert_equal(it, vec![vec![1, 0], vec![3, 2, 1, 0]]);
1907
1911
/// ```
1908
1912
fn update < F > ( self , updater : F ) -> Update < Self , F >
@@ -2162,7 +2166,7 @@ pub trait Itertools: Iterator {
2162
2166
/// ```
2163
2167
/// use itertools::Itertools;
2164
2168
///
2165
- /// let mut iter = "αβγ".chars().dropping(2);
2169
+ /// let iter = "αβγ".chars().dropping(2);
2166
2170
/// itertools::assert_equal(iter, "γ".chars());
2167
2171
/// ```
2168
2172
///
@@ -2246,14 +2250,17 @@ pub trait Itertools: Iterator {
2246
2250
///
2247
2251
/// fn process_dir_entries(entries: &[fs::DirEntry]) {
2248
2252
/// // ...
2253
+ /// # let _ = entries;
2249
2254
/// }
2250
2255
///
2251
- /// fn do_stuff() -> std:: io::Result<()> {
2256
+ /// fn do_stuff() -> io::Result<()> {
2252
2257
/// let entries: Vec<_> = fs::read_dir(".")?.try_collect()?;
2253
2258
/// process_dir_entries(&entries);
2254
2259
///
2255
2260
/// Ok(())
2256
2261
/// }
2262
+ ///
2263
+ /// # let _ = do_stuff;
2257
2264
/// ```
2258
2265
fn try_collect < T , U , E > ( self ) -> Result < U , E >
2259
2266
where
@@ -2404,6 +2411,7 @@ pub trait Itertools: Iterator {
2404
2411
/// accum = f(accum, 1);
2405
2412
/// accum = f(accum, 2);
2406
2413
/// accum = f(accum, 3);
2414
+ /// # let _ = accum;
2407
2415
/// ```
2408
2416
///
2409
2417
/// With a `start` value of 0 and an addition as folding function,
@@ -2554,16 +2562,16 @@ pub trait Itertools: Iterator {
2554
2562
/// assert_eq!((1..8).map(|x| x.to_string()).tree_reduce(f),
2555
2563
/// Some(String::from("f(f(f(1, 2), f(3, 4)), f(f(5, 6), 7))")));
2556
2564
///
2557
- /// // Like fold1 , an empty iterator produces None
2565
+ /// // Like reduce , an empty iterator produces None
2558
2566
/// assert_eq!((0..0).tree_reduce(|x, y| x * y), None);
2559
2567
///
2560
- /// // tree_reduce matches fold1 for associative operations...
2568
+ /// // tree_reduce matches reduce for associative operations...
2561
2569
/// 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));
2563
2571
///
2564
2572
/// // ...but not for non-associative ones
2565
2573
/// 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));
2567
2575
///
2568
2576
/// let mut total_len_reduce = 0;
2569
2577
/// let reduce_res = (1..100).map(|x| x.to_string())
@@ -4350,7 +4358,7 @@ pub trait Itertools: Iterator {
4350
4358
/// # Examples
4351
4359
/// ```
4352
4360
/// # 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();
4354
4362
/// assert_eq!(counts[&1], 3);
4355
4363
/// assert_eq!(counts[&3], 2);
4356
4364
/// assert_eq!(counts[&5], 1);
@@ -4376,6 +4384,7 @@ pub trait Itertools: Iterator {
4376
4384
/// # use itertools::Itertools;
4377
4385
/// struct Character {
4378
4386
/// first_name: &'static str,
4387
+ /// # #[allow(dead_code)]
4379
4388
/// last_name: &'static str,
4380
4389
/// }
4381
4390
///
0 commit comments