Skip to content

Commit d43e64d

Browse files
committed
Resolve TODOs awaiting MSRV >1.62
1 parent acb3708 commit d43e64d

File tree

5 files changed

+9
-22
lines changed

5 files changed

+9
-22
lines changed

src/adaptors/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1108,9 +1108,7 @@ where
11081108

11091109
fn next(&mut self) -> Option<Self::Item> {
11101110
let f = &mut self.f;
1111-
// TODO: once MSRV >= 1.62, use `then_some`.
1112-
self.iter
1113-
.find_map(|(count, val)| if f(val) { Some(count) } else { None })
1111+
self.iter.find_map(|(count, val)| f(val).then_some(count))
11141112
}
11151113

11161114
fn size_hint(&self) -> (usize, Option<usize>) {
@@ -1138,11 +1136,10 @@ where
11381136
{
11391137
fn next_back(&mut self) -> Option<Self::Item> {
11401138
let f = &mut self.f;
1141-
// TODO: once MSRV >= 1.62, use `then_some`.
11421139
self.iter
11431140
.by_ref()
11441141
.rev()
1145-
.find_map(|(count, val)| if f(val) { Some(count) } else { None })
1142+
.find_map(|(count, val)| f(val).then_some(count))
11461143
}
11471144

11481145
fn rfold<B, G>(self, init: B, mut func: G) -> B

src/combinations_with_replacement.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,7 @@ where
7373
Some((increment_from, increment_value)) => {
7474
// We need to update the rightmost non-max value
7575
// and all those to the right
76-
for i in &mut self.indices[increment_from..] {
77-
*i = increment_value;
78-
}
79-
// TODO: once MSRV >= 1.50, use `fill` instead:
80-
// self.indices[increment_from..].fill(increment_value);
76+
self.indices[increment_from..].fill(increment_value);
8177
false
8278
}
8379
// Otherwise, we're done

src/concat_impl.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use crate::Itertools;
2-
31
/// Combine all an iterator's elements into one element by using [`Extend`].
42
///
5-
/// [`IntoIterator`]-enabled version of [`Itertools::concat`].
3+
/// [`IntoIterator`]-enabled version of [`crate::Itertools::concat`].
64
///
75
/// This combinator will extend the first item with each of the rest of the
86
/// items of the iterator. If the iterator is empty, the default value of
@@ -19,10 +17,9 @@ where
1917
I: IntoIterator,
2018
I::Item: Extend<<<I as IntoIterator>::Item as IntoIterator>::Item> + IntoIterator + Default,
2119
{
22-
#[allow(deprecated)] //TODO: once msrv hits 1.51. replace `fold1` with `reduce`
2320
iterable
2421
.into_iter()
25-
.fold1(|mut a, b| {
22+
.reduce(|mut a, b| {
2623
a.extend(b);
2724
a
2825
})

src/kmerge_impl.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::size_hint;
2-
use crate::Itertools;
32

43
use alloc::vec::Vec;
54
use std::fmt;
@@ -128,7 +127,7 @@ impl<T, F: FnMut(&T, &T) -> bool> KMergePredicate<T> for F {
128127
/// Create an iterator that merges elements of the contained iterators using
129128
/// the ordering function.
130129
///
131-
/// [`IntoIterator`] enabled version of [`Itertools::kmerge`].
130+
/// [`IntoIterator`] enabled version of [`crate::Itertools::kmerge`].
132131
///
133132
/// ```
134133
/// use itertools::kmerge;
@@ -172,7 +171,7 @@ where
172171

173172
/// Create an iterator that merges elements of the contained iterators.
174173
///
175-
/// [`IntoIterator`] enabled version of [`Itertools::kmerge_by`].
174+
/// [`IntoIterator`] enabled version of [`crate::Itertools::kmerge_by`].
176175
pub fn kmerge_by<I, F>(
177176
iterable: I,
178177
mut less_than: F,
@@ -223,11 +222,10 @@ where
223222
}
224223

225224
fn size_hint(&self) -> (usize, Option<usize>) {
226-
#[allow(deprecated)] //TODO: once msrv hits 1.51. replace `fold1` with `reduce`
227225
self.heap
228226
.iter()
229227
.map(|i| i.size_hint())
230-
.fold1(size_hint::add)
228+
.reduce(size_hint::add)
231229
.unwrap_or((0, Some(0)))
232230
}
233231
}

tests/quick.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1511,13 +1511,12 @@ quickcheck! {
15111511
acc + val
15121512
});
15131513

1514-
// TODO: Swap `fold1` with stdlib's `reduce` when it's stabilized
15151514
let group_map_lookup = a.iter()
15161515
.map(|&b| b as u64)
15171516
.map(|i| (i % modulo, i))
15181517
.into_group_map()
15191518
.into_iter()
1520-
.map(|(key, vals)| (key, vals.into_iter().fold1(|acc, val| acc + val).unwrap()))
1519+
.map(|(key, vals)| (key, vals.into_iter().reduce(|acc, val| acc + val).unwrap()))
15211520
.collect::<HashMap<_,_>>();
15221521
assert_eq!(lookup, group_map_lookup);
15231522

0 commit comments

Comments
 (0)