#iterator #product #zip #data-structures #no-alloc

no-std itertools

Extra iterator adaptors, iterator methods, free functions, and macros

129 releases

0.13.0 May 16, 2024
0.12.1 Jan 29, 2024
0.12.0 Nov 14, 2023
0.11.0 Jun 22, 2023
0.0.3 Nov 29, 2014

#3 in Rust patterns

Download history 3495725/week @ 2024-06-26 3213411/week @ 2024-07-03 3506674/week @ 2024-07-10 3682702/week @ 2024-07-17 3867257/week @ 2024-07-24 4014144/week @ 2024-07-31 4213724/week @ 2024-08-07 4161448/week @ 2024-08-14 4436216/week @ 2024-08-21 4092880/week @ 2024-08-28 4627925/week @ 2024-09-04 4316944/week @ 2024-09-11 4240551/week @ 2024-09-18 4725961/week @ 2024-09-25 5270661/week @ 2024-10-02 4476281/week @ 2024-10-09

19,491,821 downloads per month
Used in 25,692 crates (5,533 directly)

MIT/Apache

420KB
8K SLoC

Itertools

Extra iterator adaptors, functions and macros.

Please read the API documentation here.

How to use with Cargo:

[dependencies]
itertools = "0.13.0"

How to use in your crate:

use itertools::Itertools;

How to contribute

If you're not sure what to work on, try checking the help wanted label.

See our CONTRIBUTING.md for a detailed guide.

License

Dual-licensed to be compatible with the Rust project.

Licensed under the Apache License, Version 2.0 https://www.apache.org/licenses/LICENSE-2.0 or the MIT license https://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.


lib.rs:

Extra iterator adaptors, functions and macros.

To extend Iterator with methods in this crate, import the Itertools trait:

use itertools::Itertools;

Now, new methods like interleave are available on all iterators:

use itertools::Itertools;

let it = (1..3).interleave(vec![-1, -2]);
itertools::assert_equal(it, vec![1, -1, 2, -2]);

Most iterator methods are also provided as functions (with the benefit that they convert parameters using IntoIterator):

use itertools::interleave;

for elt in interleave(&[1, 2, 3], &[2, 3, 4]) {
    /* loop body */
}

Crate Features

  • use_std
    • Enabled by default.
    • Disable to compile itertools using #![no_std]. This disables any item that depend on allocations (see the use_alloc feature) and hash maps (like unique, counts, into_grouping_map and more).
  • use_alloc
    • Enabled by default.
    • Enables any item that depend on allocations (like chunk_by, kmerge, join and many more).

Rust Version

This version of itertools requires Rust 1.43.1 or later.

Dependencies