Skip to content

Commit 8bae261

Browse files
committed
Merge remote-tracking branch 'upstream/master' into merge_join_by_missing_specializations
# Conflicts: # src/merge_join.rs
2 parents a0eb01c + 505e0f4 commit 8bae261

File tree

13 files changed

+70
-22
lines changed

13 files changed

+70
-22
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
/target/
1+
/target
22
Cargo.lock

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "itertools"
3-
version = "0.8.1"
3+
version = "0.8.2"
44

55
license = "MIT/Apache-2.0"
66
repository = "https://github.com/bluss/rust-itertools"
@@ -13,6 +13,9 @@ keywords = ["iterator", "data-structure", "zip", "product", "group-by"]
1313
categories = ["algorithms", "rust-patterns"]
1414
exclude = ["/bors.toml"]
1515

16+
[package.metadata.release]
17+
no-dev-version = true
18+
1619
[lib]
1720
bench = false
1821
test = false
@@ -36,6 +39,3 @@ use_std = []
3639

3740
[profile]
3841
bench = { debug = true }
39-
40-
[package.metadata.release]
41-
no-dev-version = true

README.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ then it can't be accepted into ``libcore``, and you should propose it for ``iter
4747

4848
Recent Changes
4949
--------------
50+
- 0.8.2
51+
52+
- Use :code:`slice::iter` instead of :code:`into_iter` to avoid future breakage (`#378 <https://github.com/rust-itertools/itertools/pull/378>`_, by `@LukasKalbertodt <https://github.com/LukasKalbertodt>`_)
5053

5154
- 0.8.1
5255

src/adaptors/mod.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ impl<I, A> Iterator for WhileSome<I>
908908
///
909909
/// See [`.tuple_combinations()`](../trait.Itertools.html#method.tuple_combinations) for more
910910
/// information.
911-
#[derive(Debug)]
911+
#[derive(Clone, Debug)]
912912
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
913913
pub struct TupleCombinations<I, T>
914914
where I: Iterator,
@@ -947,7 +947,7 @@ impl<I, T> Iterator for TupleCombinations<I, T>
947947
}
948948
}
949949

950-
#[derive(Debug)]
950+
#[derive(Clone, Debug)]
951951
pub struct Tuple1Combination<I> {
952952
iter: I,
953953
}
@@ -972,7 +972,7 @@ impl<I: Iterator> HasCombination<I> for (I::Item,) {
972972

973973
macro_rules! impl_tuple_combination {
974974
($C:ident $P:ident ; $A:ident, $($I:ident),* ; $($X:ident)*) => (
975-
#[derive(Debug)]
975+
#[derive(Clone, Debug)]
976976
pub struct $C<I: Iterator> {
977977
item: Option<I::Item>,
978978
iter: I,
@@ -1036,6 +1036,7 @@ impl_tuple_combination!(Tuple4Combination Tuple3Combination ; A, A, A, A, A; a b
10361036
/// An iterator adapter to apply `Into` conversion to each element.
10371037
///
10381038
/// See [`.map_into()`](../trait.Itertools.html#method.map_into) for more information.
1039+
#[derive(Clone)]
10391040
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
10401041
pub struct MapInto<I, R> {
10411042
iter: I,
@@ -1093,6 +1094,7 @@ where
10931094
/// An iterator adapter to apply a transformation within a nested `Result`.
10941095
///
10951096
/// See [`.map_results()`](../trait.Itertools.html#method.map_results) for more information.
1097+
#[derive(Clone)]
10961098
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
10971099
pub struct MapResults<I, F> {
10981100
iter: I,
@@ -1142,6 +1144,7 @@ impl<I, F, T, U, E> Iterator for MapResults<I, F>
11421144
/// An iterator adapter to get the positions of each element that matches a predicate.
11431145
///
11441146
/// See [`.positions()`](../trait.Itertools.html#method.positions) for more information.
1147+
#[derive(Clone)]
11451148
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
11461149
pub struct Positions<I, F> {
11471150
iter: I,
@@ -1200,6 +1203,7 @@ impl<I, F> DoubleEndedIterator for Positions<I, F>
12001203
/// An iterator adapter to apply a mutating function to each element before yielding it.
12011204
///
12021205
/// See [`.update()`](../trait.Itertools.html#method.update) for more information.
1206+
#[derive(Clone)]
12031207
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
12041208
pub struct Update<I, F> {
12051209
iter: I,

src/combinations.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ pub struct Combinations<I: Iterator> {
1313
first: bool,
1414
}
1515

16+
impl<I> Clone for Combinations<I>
17+
where I: Clone + Iterator,
18+
I::Item: Clone,
19+
{
20+
fn clone(&self) -> Self {
21+
Combinations {
22+
k: self.k,
23+
indices: self.indices.clone(),
24+
pool: self.pool.clone(),
25+
first: self.first,
26+
}
27+
}
28+
}
29+
1630
impl<I> fmt::Debug for Combinations<I>
1731
where I: Iterator + fmt::Debug,
1832
I::Item: fmt::Debug,

src/format.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use std::cell::RefCell;
77
/// exhausted.
88
///
99
/// See [`.format_with()`](../trait.Itertools.html#method.format_with) for more information.
10+
#[derive(Clone)]
1011
pub struct FormatWith<'a, I, F> {
1112
sep: &'a str,
1213
/// FormatWith uses interior mutability because Display::fmt takes &self.

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,10 +505,11 @@ pub trait Itertools : Iterator {
505505
///
506506
/// // Note: The `&` is significant here, `GroupBy` is iterable
507507
/// // only by reference. You can also call `.into_iter()` explicitly.
508+
/// let mut data_grouped = Vec::new();
508509
/// for (key, group) in &data.into_iter().group_by(|elt| *elt >= 0) {
509-
/// // Check that the sum of each group is +/- 4.
510-
/// assert_eq!(4, group.sum::<i32>().abs());
510+
/// data_grouped.push((key, group.collect()));
511511
/// }
512+
/// assert_eq!(data_grouped, vec![(true, vec![1, 3]), (false, vec![-2, -2]), (true, vec![1, 0, 1, 2])]);
512513
/// ```
513514
#[cfg(feature = "use_std")]
514515
fn group_by<K, F>(self, key: F) -> GroupBy<K, Self, F>

src/merge_join.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ pub struct MergeJoinBy<I: Iterator, J: Iterator, F> {
3232
}
3333

3434
impl<I, J, F> Clone for MergeJoinBy<I, J, F>
35-
where
36-
I: Iterator,
37-
J: Iterator,
38-
PutBack<Fuse<I>>: Clone,
39-
PutBack<Fuse<J>>: Clone,
40-
F: Clone,
35+
where I: Iterator,
36+
J: Iterator,
37+
PutBack<Fuse<I>>: Clone,
38+
PutBack<Fuse<J>>: Clone,
39+
F: Clone,
4140
{
4241
fn clone(&self) -> Self {
4342
MergeJoinBy {
@@ -95,7 +94,7 @@ impl<I, J, F> Iterator for MergeJoinBy<I, J, F>
9594
let lower = ::std::cmp::max(a_lower, b_lower);
9695

9796
let upper = match (a_upper, b_upper) {
98-
(Some(x), Some(y)) => Some(x + y),
97+
(Some(x), Some(y)) => x.checked_add(y),
9998
_ => None,
10099
};
101100

src/permutations.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,19 @@ pub struct Permutations<I: Iterator> {
1414
state: PermutationState,
1515
}
1616

17-
#[derive(Debug)]
17+
impl<I> Clone for Permutations<I>
18+
where I: Clone + Iterator,
19+
I::Item: Clone,
20+
{
21+
fn clone(&self) -> Self {
22+
Permutations {
23+
vals: self.vals.clone(),
24+
state: self.state.clone(),
25+
}
26+
}
27+
}
28+
29+
#[derive(Clone, Debug)]
1830
enum PermutationState {
1931
StartUnknownLen {
2032
k: usize,
@@ -27,7 +39,7 @@ enum PermutationState {
2739
Empty,
2840
}
2941

30-
#[derive(Debug)]
42+
#[derive(Clone, Debug)]
3143
enum CompleteState {
3244
Start {
3345
n: usize,

src/repeatn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
///
44
/// See [`repeat_n()`](../fn.repeat_n.html) for more information.
55
#[must_use = "iterators are lazy and do nothing unless consumed"]
6-
#[derive(Debug)]
6+
#[derive(Clone, Debug)]
77
pub struct RepeatN<A> {
88
elt: Option<A>,
99
n: usize,

0 commit comments

Comments
 (0)