Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump MSRV to 1.63.0 #960

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master
with:
# Here, it does not trigger a PR from dependabot.
toolchain: 1.43.1
toolchain: 1.63.0
- run: cargo no-dev-deps check

test:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ categories = ["algorithms", "rust-patterns", "no-std", "no-std::no-alloc"]
edition = "2018"

# When bumping, please resolve all `#[allow(clippy::*)]` that are newly resolvable.
rust-version = "1.43.1"
rust-version = "1.63.0"

[lib]
bench = false
Expand Down
2 changes: 1 addition & 1 deletion benches/specializations.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#![allow(unstable_name_collisions, clippy::incompatible_msrv)]
#![allow(unstable_name_collisions)]

use criterion::black_box;
use criterion::BenchmarkId;
Expand Down
7 changes: 2 additions & 5 deletions src/adaptors/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1108,9 +1108,7 @@ where

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

fn size_hint(&self) -> (usize, Option<usize>) {
Expand Down Expand Up @@ -1138,11 +1136,10 @@ where
{
fn next_back(&mut self) -> Option<Self::Item> {
let f = &mut self.f;
// TODO: once MSRV >= 1.62, use `then_some`.
self.iter
.by_ref()
.rev()
.find_map(|(count, val)| if f(val) { Some(count) } else { None })
.find_map(|(count, val)| f(val).then_some(count))
}

fn rfold<B, G>(self, init: B, mut func: G) -> B
Expand Down
6 changes: 1 addition & 5 deletions src/combinations_with_replacement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,7 @@ where
Some((increment_from, increment_value)) => {
// We need to update the rightmost non-max value
// and all those to the right
for i in &mut self.indices[increment_from..] {
*i = increment_value;
}
// TODO: once MSRV >= 1.50, use `fill` instead:
// self.indices[increment_from..].fill(increment_value);
self.indices[increment_from..].fill(increment_value);
false
}
// Otherwise, we're done
Expand Down
7 changes: 2 additions & 5 deletions src/concat_impl.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
use crate::Itertools;

/// Combine all an iterator's elements into one element by using [`Extend`].
///
/// [`IntoIterator`]-enabled version of [`Itertools::concat`].
/// [`IntoIterator`]-enabled version of [`Itertools::concat`](crate::Itertools::concat).
///
/// This combinator will extend the first item with each of the rest of the
/// items of the iterator. If the iterator is empty, the default value of
Expand All @@ -19,10 +17,9 @@ where
I: IntoIterator,
I::Item: Extend<<<I as IntoIterator>::Item as IntoIterator>::Item> + IntoIterator + Default,
{
#[allow(deprecated)] //TODO: once msrv hits 1.51. replace `fold1` with `reduce`
iterable
.into_iter()
.fold1(|mut a, b| {
.reduce(|mut a, b| {
a.extend(b);
a
})
Expand Down
8 changes: 3 additions & 5 deletions src/kmerge_impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::size_hint;
use crate::Itertools;

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

/// Create an iterator that merges elements of the contained iterators.
///
/// [`IntoIterator`] enabled version of [`Itertools::kmerge_by`].
/// [`IntoIterator`] enabled version of [`Itertools::kmerge_by`](crate::Itertools::kmerge_by).
pub fn kmerge_by<I, F>(
iterable: I,
mut less_than: F,
Expand Down Expand Up @@ -223,11 +222,10 @@ where
}

fn size_hint(&self) -> (usize, Option<usize>) {
#[allow(deprecated)] //TODO: once msrv hits 1.51. replace `fold1` with `reduce`
self.heap
.iter()
.map(|i| i.size_hint())
.fold1(size_hint::add)
.reduce(size_hint::add)
.unwrap_or((0, Some(0)))
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
//!
//! ## Rust Version
//!
//! This version of itertools requires Rust 1.43.1 or later.
//! This version of itertools requires Rust 1.63.0 or later.

#[cfg(not(feature = "use_std"))]
extern crate core as std;
Expand Down
4 changes: 1 addition & 3 deletions tests/quick.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ where
let mut it = get_it();

for _ in 0..(counts.len() - 1) {
#[allow(clippy::manual_assert)]
Philippe-Cholet marked this conversation as resolved.
Show resolved Hide resolved
if it.next().is_none() {
panic!("Iterator shouldn't be finished, may not be deterministic");
}
Expand Down Expand Up @@ -1512,13 +1511,12 @@ quickcheck! {
acc + val
});

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

Expand Down