- Documented iteration order guarantee for
Itertools::[tuple_]combinations
(#822) - Documented possible panic in
iterate
(#842) - Implemented
Clone
andDebug
forDiff
(#845) - Implemented
Debug
forWithPosition
(#859) - Implemented
Eq
forMinMaxResult
(#838) - Implemented
From<EitherOrBoth<A, B>>
forOption<Either<A, B>>
(#843) - Implemented
PeekingNext
forRepeatN
(#855)
- Made
CoalesceBy
lazy (#801) - Optimized
Filter[Map]Ok::next
,Itertools::partition
,Unique[By]::next[_back]
(#818) - Optimized
Itertools::find_position
(#837) - Optimized
Positions::next[_back]
(#816) - Optimized
ZipLongest::fold
(#854) - Relaxed
Debug
bounds forGroupingMapBy
(#860) - Specialized
ExactlyOneError::fold
(#826) - Specialized
Interleave[Shortest]::fold
(#849) - Specialized
MultiPeek::fold
(#820) - Specialized
PadUsing::[r]fold
(#825) - Specialized
PeekNth::fold
(#824) - Specialized
Positions::[r]fold
(#813) - Specialized
PutBackN::fold
(#823) - Specialized
RepeatN::[r]fold
(#821) - Specialized
TakeWhileInclusive::fold
(#851) - Specialized
ZipLongest::rfold
(#848)
- Added test coverage in CI (#847, #856)
- Added semver check in CI (#784)
- Enforced
clippy
in CI (#740) - Enforced
rustdoc
in CI (#840) - Improved specialization tests (#807)
- More specialization benchmarks (#806)
- Made
take_while_inclusive
consume iterator by value (#709) - Added
Clone
bound toUnique
(#777)
- Added
Itertools::try_len
(#723) - Added free function
sort_unstable
(#796) - Added
GroupMap::fold_with
(#778, #785) - Added
PeekNth::{peek_mut, peek_nth_mut}
(#716) - Added
PeekNth::{next_if, next_if_eq}
(#734) - Added conversion into
(Option<A>,Option<B>)
toEitherOrBoth
(#713) - Added conversion from
Either<A, B>
toEitherOrBoth<A, B>
(#715) - Implemented
ExactSizeIterator
forTuples
(#761) - Implemented
ExactSizeIterator
for(Circular)TupleWindows
(#752) - Made
EitherOrBoth<T>
a shorthand forEitherOrBoth<T, T>
(#719)
- Added missing
#[must_use]
annotations on iterator adaptors (#794) - Made
Combinations
lazy (#795) - Made
Intersperse(With)
lazy (#797) - Made
Permutations
lazy (#793) - Made
Product
lazy (#800) - Made
TupleWindows
lazy (#602) - Specialized
Combinations::{count, size_hint}
(#729) - Specialized
CombinationsWithReplacement::{count, size_hint}
(#737) - Specialized
Powerset::fold
(#765) - Specialized
Powerset::count
(#735) - Specialized
TupleCombinations::{count, size_hint}
(#763) - Specialized
TupleCombinations::fold
(#775) - Specialized
WhileSome::fold
(#780) - Specialized
WithPosition::fold
(#772) - Specialized
ZipLongest::fold
(#774) - Changed
{min, max}_set*
operations requirealloc
feature, instead ofstd
(#760) - Improved documentation of
tree_fold1
(#787) - Improved documentation of
permutations
(#724) - Fixed typo in documentation of
multiunzip
(#770)
- Improved specialization tests (#799, #786, #782)
- Simplified implementation of
Permutations
(#739, #748, #790) - Combined
Merge
/MergeBy
/MergeJoinBy
implementations (#736) - Simplified
Permutations::size_hint
(#739) - Fix wrapping arithmetic in benchmarks (#770)
- Enforced
rustfmt
in CI (#751) - Disallowed compile warnings in CI (#720)
- Used
cargo hack
to check MSRV (#754)
- Make
Itertools::merge_join_by
also accept functions returning bool (#704) - Implement
PeekingNext
transitively over mutable references (#643) - Change
with_position
to yield(Position, Item)
instead ofPosition<Item>
(#699)
- Add
Itertools::take_while_inclusive
(#616) - Implement
PeekingNext
forPeekingTakeWhile
(#644) - Add
EitherOrBoth::{just_left, just_right, into_left, into_right, as_deref, as_deref_mut, left_or_insert, right_or_insert, left_or_insert_with, right_or_insert_with, insert_left, insert_right, insert_both}
(#629) - Implement
Clone
forCircularTupleWindows
(#686) - Implement
Clone
forChunks
(#683) - Add
Itertools::process_results
(#680)
- Use
Cell
instead ofRefCell
inFormat
andFormatWith
(#608) - CI tweaks (#674, #675)
- Document and test the difference between stable and unstable sorts (#653)
- Fix documentation error on
Itertools::max_set_by_key
(#692) - Move MSRV metadata to
Cargo.toml
(#672) - Implement
equal
withIterator::eq
(#591)
- Maintenance
- Add
EitherOrBoth::or
andEitherOrBoth::or_else
(#593) - Add
min_set
,max_set
et al. (#613, #323) - Use
either/use_std
(#628) - Documentation fixes (#612, #625, #632, #633, #634, #638)
- Code maintenance (#623, #624, #627, #630)
- Maintenance
- Add
Itertools::multiunzip
(#362, #565) - Add
intersperse
andintersperse_with
free functions (#555) - Add
Itertools::sorted_by_cached_key
(#424, #575) - Specialize
ProcessResults::fold
(#563) - Fix subtraction overflow in
DuplicatesBy::size_hint
(#552) - Fix specialization tests (#574)
- More
Debug
impls (#573) - Deprecate
fold1
(usereduce
instead) (#580) - Documentation fixes (
HomogenousTuple
,into_group_map
,into_group_map_by
,MultiPeek::peek
) (#543 et al.)
- Add
Itertools::contains
(#514) - Add
Itertools::counts_by
(#515) - Add
Itertools::partition_result
(#511) - Add
Itertools::all_unique
(#241) - Add
Itertools::duplicates
andItertools::duplicates_by
(#502) - Add
chain!
(#525) - Add
Itertools::at_most_one
(#523) - Add
Itertools::flatten_ok
(#527) - Add
EitherOrBoth::or_default
(#583) - Add
Itertools::find_or_last
andItertools::find_or_first
(#535) - Implement
FusedIterator
forFilterOk
,FilterMapOk
,InterleaveShortest
,KMergeBy
,MergeBy
,PadUsing
,Positions
,Product
,RcIter
,TupleWindows
,Unique
,UniqueBy
,Update
,WhileSome
,Combinations
,CombinationsWithReplacement
,Powerset
,RepeatN
, andWithPosition
(#550) - Implement
FusedIterator
forInterleave
,IntersperseWith
, andZipLongest
(#548)
- Increase minimum supported Rust version to 1.32.0
- Improve macro hygiene (#507)
- Add
Itertools::powerset
(#335) - Add
Itertools::sorted_unstable
,Itertools::sorted_unstable_by
, andItertools::sorted_unstable_by_key
(#494) - Implement
Error
forExactlyOneError
(#484) - Undeprecate
Itertools::fold_while
(#476) - Tuple-related adapters work for tuples of arity up to 12 (#475)
use_alloc
feature for users who havealloc
, but notstd
(#474)- Add
Itertools::k_smallest
(#473) - Add
Itertools::into_grouping_map
andGroupingMap
(#465) - Add
Itertools::into_grouping_map_by
andGroupingMapBy
(#465) - Add
Itertools::counts
(#468) - Add implementation of
DoubleEndedIterator
forUnique
(#442) - Add implementation of
DoubleEndedIterator
forUniqueBy
(#442) - Add implementation of
DoubleEndedIterator
forZip
(#346) - Add
Itertools::multipeek
(#435) - Add
Itertools::dedup_with_count
andDedupWithCount
(#423) - Add
Itertools::dedup_by_with_count
andDedupByWithCount
(#423) - Add
Itertools::intersperse_with
andIntersperseWith
(#381) - Add
Itertools::filter_ok
andFilterOk
(#377) - Add
Itertools::filter_map_ok
andFilterMapOk
(#377) - Deprecate
Itertools::fold_results
, useItertools::fold_ok
instead (#377) - Deprecate
Itertools::map_results
, useItertools::map_ok
instead (#377) - Deprecate
FoldResults
, useFoldOk
instead (#377) - Deprecate
MapResults
, useMapOk
instead (#377) - Add
Itertools::circular_tuple_windows
andCircularTupleWindows
(#350) - Add
peek_nth
andPeekNth
(#303)
- Fix potential overflow in
MergeJoinBy::size_hint
(#385) - Add
derive(Clone)
where possible (#382) - Add
try_collect
method (#394) - Add
HomogeneousTuple
trait (#389) - Fix
combinations(0)
andcombinations_with_replacement(0)
(#383) - Don't require
ParitalEq
to theItem
ofDedupBy
(#397) - Implement missing specializations on the
PutBack
adaptor and on theMergeJoinBy
iterator (#372) - Add
position_*
methods (#412) - Derive
Hash
forEitherOrBoth
(#417) - Increase minimum supported Rust version to 1.32.0
- Use
slice::iter
instead ofinto_iter
to avoid future breakage (#378, by @LukasKalbertodt)
-
Added a
.exactly_one()
iterator method that, on success, extracts the single value of an iterator ; by @Xaeroxe -
Added combinatory iterator adaptors:
-
[0, 1, 2].iter().permutations(2)
yields[ vec![0, 1], vec![0, 2], vec![1, 0], vec![1, 2], vec![2, 0], vec![2, 1], ]
; by @tobz1000
-
.combinations_with_replacement(k)
:[0, 1, 2].iter().combinations_with_replacement(2)
yields[ vec![0, 0], vec![0, 1], vec![0, 2], vec![1, 1], vec![1, 2], vec![2, 2], ]
; by @tommilligan
-
For reference, these methods join the already existing
.combinations(k)
:[0, 1, 2].iter().combinations(2)
yields[ vec![0, 1], vec![0, 2], vec![1, 2], ]
-
-
Improved the performance of
.fold()
-based internal iteration for the.intersperse()
iterator ; by @jswrenn -
Added
.dedup_by()
,.merge_by()
and.kmerge_by()
adaptors that work like.dedup()
,.merge()
and.kmerge()
, but taking an additional custom comparison closure parameter. ; by @phimuemue -
Improved the performance of
.all_equal()
; by @fyrchik -
Loosened the bounds on
.partition_map()
to take just aFnMut
closure rather than aFn
closure, and made its implementation use internal iteration for better performance ; by @danielhenrymantilla -
Added convenience methods to
EitherOrBoth
elements yielded from the.zip_longest()
iterator adaptor ; by @Avi-D-coder -
Added
.sum1()
and.product1()
iterator methods that respectively try to return the sum and the product of the elements of an iterator when it is not empty, otherwise they returnNone
; by @Emerentius
- Added new adaptor
.map_into()
for conversions usingInto
by @vorner - Improved
Itertools
docs by @JohnHeitmann - The return type of
.sorted_by_by_key()
is now an iterator, not a Vec. - The return type of the
izip!(x, y)
macro with exactly two arguments is now the usualIterator::zip
. - Remove
.flatten()
in favour of std's.flatten()
- Deprecate
.foreach()
in favour of std's.for_each()
- Deprecate
.step()
in favour of std's.step_by()
- Deprecate
repeat_call
in favour of std'srepeat_with
- Deprecate
.fold_while()
in favour of std's.try_fold()
- Require Rust 1.24 as minimal version.
- Add convenience methods to
EitherOrBoth
, making it more similar toOption
andEither
by @jethrogb
- No changes.
- New inclusion policy: See the readme about suggesting features for std before accepting them in itertools.
- The
FoldWhile
type now implementsEq
andPartialEq
by @jturner314
- Add new iterator method
.tree_fold1()
which is like.fold1()
except items are combined in a tree structure (see its docs). By @scottmcm - Add more
Debug
impls by @phimuemue: KMerge, KMergeBy, MergeJoinBy, ConsTuples, Intersperse, ProcessResults, RcIter, Tee, TupleWindows, Tee, ZipLongest, ZipEq, Zip.
- Add new iterator method
.into_group_map() -> HashMap<K, Vec<V>>
which turns an iterator of(K, V)
elements into such a hash table, where values are grouped by key. By @tobz1000 - Add new free function
flatten
for the.flatten()
adaptor. NOTE: recent Rust nightlies haveIterator::flatten
and thus a clash with our flatten adaptor. One workaround is to use the itertoolsflatten
free function.
- Add new adaptor
.multi_cartesian_product()
which is an n-ary product iterator by @tobz1000 - Add new method
.sorted_by_key()
by @Xion - Provide simpler and faster
.count()
for.unique()
and.unique_by()
.multipeek()
now implementsPeekingNext
, by @nicopap.
- Add new adaptor
.update()
by @lucasem; this adaptor is used to modify an element before passing it on in an iterator chain.
- Add new method
.collect_tuple()
by @matklad; it makes a tuple out of the iterator's elements if the number of them matches exactly. - Implement
fold
andcollect
for.map_results()
which means it reuses the code of the standard.map()
for these methods.
- Add new adaptor
.merge_join_by
by @srijs; a heterogeneous merge join for two ordered sequences.
- Iterator adaptors and iterators in itertools now use the same
must_use
reminder that the standard library adaptors do, by @matematikaedit and @bluss “iterator adaptors are lazy and do nothing unless consumed”.
- Faster
izip!()
by @krdlnizip!()
is now a wrapper for repeated regular.zip()
and a single.map()
. This means it optimizes as well as the standard library.zip()
it uses. Note:multizip
andizip!()
are now different! The former has a named type but the latter optimizes better.
- Faster
.unique()
no_std
support, which is opt-in!- Many lovable features are still there without std, like
izip!()
or.format()
or.merge()
, but not those that use collections.
- Many lovable features are still there without std, like
- Trait bounds were required up front instead of just on the type:
group_by
'sPartialEq
by @Phlosioneer andrepeat_call
'sFnMut
. - Removed deprecated constructor
Zip::new
— useizip!()
ormultizip()
- Fix bug in
.cartesian_product()
's fold (which only was visible for unfused iterators).
- Add specific
fold
implementations for.cartesian_product()
andcons_tuples()
, which improves their performance in fold, foreach, and iterator consumers derived from them.
- Add iterator adaptor
.positions(predicate)
by @tmccombs
- Add function
process_results
which can “lift” a function of the regular values of an iterator so that it can process theOk
values from an iterator ofResults
instead, by @shepmaster - Add iterator method
.concat()
which combines all iterator elements into a single collection using theExtend
trait, by @srijs
- Better size hint testing and subsequent size hint bugfixes by @rkarp. Fixes bugs in product,
interleave_shortest
size hints. - New iterator method
.all_equal()
by @phimuemue
- Deprecated names were removed in favour of their replacements
.flatten()
does not implement double ended iteration anymore.fold_while()
uses&mut self
and returnsFoldWhile<T>
, for composability #168.foreach()
and.fold1()
useself
, like.fold()
does..combinations(0)
now produces a single empty vector. #174
- Add itertools method
.kmerge_by()
(and corresponding free function) - Relaxed trait requirement of
.kmerge()
and.minmax()
to PartialOrd.
- Add multipeek method
.reset_peek()
- Add categories
- Add iterator adaptor
.peeking_take_while()
and its traitPeekingNext
.
- Add iterator adaptor
.with_position()
- Fix multipeek's performance for long peeks by using
VecDeque
.
- Add
.map_results()
- Many more adaptors now implement
Debug
- Add free function constructor
repeat_n
.RepeatN::new
is now deprecated.
- Add infinite generator function
iterate
, that takes a seed and a closure.
- Special-cased
.fold()
for flatten and put back..foreach()
now uses fold on the iterator, to pick up any iterator specific loop implementation. .combinations(n)
asserts up front thatn != 0
, instead of running into an error on the second iterator element.
- Add
.tuples::<T>()
that iterates by two, three or four elements at a time (whereT
is a tuple type). - Add
.tuple_windows::<T>()
that iterates using a window of the two, three or four most recent elements. - Add
.next_tuple::<T>()
method, that picks the next two, three or four elements in one go. .interleave()
now has an accurate size hint.
- Workaround module/function name clash that made racer crash on completing itertools. Only internal changes needed.
- Release announcement
- Renamed:
combinations
is nowtuple_combinations
combinations_n
tocombinations
group_by_lazy
,chunks_lazy
togroup_by
,chunks
Unfold::new
tounfold()
RepeatCall::new
torepeat_call()
Zip::new
tomultizip
PutBack::new
,PutBackN::new
toput_back
,put_back_n
PutBack::with_value
is now a builder setter, not a constructorMultiPeek::new
,.multipeek()
tomultipeek()
format
toformat_with
andformat_default
toformat
.into_rc()
torciter
Partition
enum is nowEither
- Module reorganization:
- All iterator structs are under
itertools::structs
but also reexported to the top level, for backwards compatibility - All free functions are reexported at the root,
itertools::free
will be removed in the next version
- All iterator structs are under
- Removed:
ZipSlices
, use.zip()
instead.enumerate_from()
,ZipTrusted
, due to being unstable.mend_slices()
, moved to crateodds
- Stride, StrideMut, moved to crate
odds
linspace()
, moved to crateitertools-num
.sort_by()
, use.sorted_by()
.is_empty_hint()
, use.size_hint()
.dropn()
, use.dropping()
.map_fn()
, use.map()
.slice()
, use.take()
/.skip()
- helper traits in
misc
new
constructors on iterator structs, useItertools
trait or free functions insteaditertools::size_hint
is now private
- Behaviour changes:
format
andformat_with
helpers now panic if you try to format them more than once.repeat_call
is not double ended anymore
- New features:
- tuple flattening iterator is constructible with
cons_tuples
- itertools reexports
Either
from theeither
crate.Either<L, R>
is an iterator whenL, R
are. MinMaxResult
now implementsCopy
andClone
tuple_combinations
supports 1-4 tuples of combinations (previously just 2)
- tuple flattening iterator is constructible with
- Add
.minmax_by()
- Add
itertools::free::cloned
- Add
itertools::free::rciter
- Improve
.step(n)
slightly to take advantage of specialized Fuse better.
- Only changes related to the "unstable" crate feature. This feature is more or less deprecated.
- Use deprecated warnings when unstable is enabled.
.enumerate_from()
will be removed imminently since it's using a deprecated libstd trait.
- Use deprecated warnings when unstable is enabled.
- Fix bug in
.kmerge()
that caused it to often produce the wrong order #134
- Improve precision of the
interleave_shortest
adaptor's size hint (it is now computed exactly when possible).
- Fixup on top of the workaround in 0.4.14. A function in
itertools::free
was removed by mistake and now it is added back again.
- Workaround an upstream regression in a Rust nightly build that broke compilation of of
itertools::free::{interleave, merge}
- Add
.minmax()
and.minmax_by_key()
, iterator methods for finding both minimum and maximum in one scan. - Add
.format_default()
, a simpler version of.format()
(lazy formatting for iterators).
- Add
.zip_eq()
, an adaptor like.zip()
except it ensures iterators of inequal length don't pass silently (instead it panics). - Add
.fold_while()
, an iterator method that is a fold that can short-circuit. - Add
.partition_map()
, an iterator method that can separate elements into two collections.
- Add
.get()
forStride{,Mut}
and.get_mut()
forStrideMut
- Improve performance of
.kmerge()
- Add k-ary merge adaptor
.kmerge()
- Fix a bug in
.islice()
with rangesa..b
where a> b
.
- Implement
Clone
,Debug
forLinspace
- Add function
diff_with()
that compares two iterators - Add
.combinations_n()
, an n-ary combinations iterator - Add methods
PutBack::with_value
andPutBack::into_parts
.
- Add method
.sorted()
- Add module
itertools::free
with free function variants of common iterator adaptors and methods. For exampleenumerate(iterable)
,rev(iterable)
, and so on.
- Add
.flatten()
- Allow composing
ZipSlices
with itself
- Write
iproduct!()
as a single expression; this allows temporary values in its arguments.
- Add
.fold_options()
- Require Rust 1.1 or later
- Update
.dropping()
to take advantage of.nth()
.merge()
,.unique()
and.dedup()
now perform better due to not using function pointers- Add free functions
enumerate()
andrev()
- Breaking changes:
- Return types of
.merge()
and.merge_by()
renamed and changed - Method
Merge::new
removed .merge_by()
now takes a closure that returns bool.- Return type of
.dedup()
changed - Return type of
.mend_slices()
changed - Return type of
.unique()
changed - Removed function
times()
, structTimes
: use a range instead - Removed deprecated macro
icompr!()
- Removed deprecated
FnMap
and method.fn_map()
: use.map_fn()
.interleave_shortest()
is no longer guaranteed to act like fused
- Return types of
- Rename
.sort_by()
to.sorted_by()
. Old name is deprecated. - Fix well-formedness warnings from RFC 1214, no user visible impact
- Improve performance of
.merge()
's ordering function slightly
- Added
.chunks()
, similar to (and based on).group_by_lazy()
. - Tweak linspace to match numpy.linspace and make it double ended.
- Added
ZipSlices
, a fast zip for slices
- Remove
Debug
impl forFormat
, it will have different use later
- Optimize
.group_by_lazy()
- Added
.group_by_lazy()
, a possibly nonallocating group by - Added
.format()
, a nonallocating formatting helper for iterators - Remove uses of
RandomAccessIterator
since it has been deprecated in Rust.
- Added (adopted)
Unfold
from Rust
- Added adaptors
.unique()
,.unique_by()
- Added method
.sort_by()
- Added adaptor
.while_some()
- Added adaptor
.interleave_shortest()
- Added adaptor
.pad_using()
- Added
assert_equal
function
- Bugfix
.combinations()
size_hint
.
- Added source
RepeatCall
- Added adaptor
PutBackN
- Added adaptor
.combinations()
- Added
itertools::partition
, partition a sequence in place based on a predicate. - Deprecate
icompr!()
with no replacement.
.map_fn()
replaces deprecated.fn_map()
.
.take_while_ref()
by-ref adaptor.coalesce()
adaptor.mend_slices()
adaptor
.dropping_back()
method.fold1()
method.is_empty_hint()
method