From c46f78dace07885c669fa010e04ec6b706aa810d Mon Sep 17 00:00:00 2001 From: Philippe Cholet <44676486+Philippe-Cholet@users.noreply.github.com> Date: Sat, 23 Sep 2023 11:08:46 +0200 Subject: [PATCH 1/2] `try_collect` without `use_alloc` We can want to collect to a stack-based structure such as `arrayvec`. --- src/lib.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 458ffe67c..77bc2aad2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -70,7 +70,6 @@ use std::hash::Hash; use std::iter::{once, IntoIterator}; #[cfg(feature = "use_alloc")] type VecIntoIter = alloc::vec::IntoIter; -#[cfg(feature = "use_alloc")] use std::iter::FromIterator; #[macro_use] @@ -2214,7 +2213,6 @@ pub trait Itertools: Iterator { /// Ok(()) /// } /// ``` - #[cfg(feature = "use_alloc")] fn try_collect(self) -> Result where Self: Sized + Iterator>, From de163352e4c855725de82f0d6adca378fe85e8b7 Mon Sep 17 00:00:00 2001 From: Philippe Cholet <44676486+Philippe-Cholet@users.noreply.github.com> Date: Sat, 23 Sep 2023 12:16:51 +0200 Subject: [PATCH 2/2] `extrema_set` only needs `alloc` --- src/extrema_set.rs | 2 ++ src/lib.rs | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/extrema_set.rs b/src/extrema_set.rs index ae128364c..d24114c6d 100644 --- a/src/extrema_set.rs +++ b/src/extrema_set.rs @@ -1,3 +1,5 @@ +#![cfg(feature = "use_alloc")] +use alloc::{vec, vec::Vec}; use std::cmp::Ordering; /// Implementation guts for `min_set`, `min_set_by`, and `min_set_by_key`. diff --git a/src/lib.rs b/src/lib.rs index 77bc2aad2..3d5f05c4f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -177,7 +177,7 @@ mod diff; #[cfg(feature = "use_std")] mod duplicates_impl; mod exactly_one_err; -#[cfg(feature = "use_std")] +#[cfg(feature = "use_alloc")] mod extrema_set; mod flatten_ok; mod format; @@ -3169,7 +3169,7 @@ pub trait Itertools: Iterator { /// /// The elements can be floats but no particular result is guaranteed /// if an element is NaN. - #[cfg(feature = "use_std")] + #[cfg(feature = "use_alloc")] fn min_set(self) -> Vec where Self: Sized, @@ -3202,7 +3202,7 @@ pub trait Itertools: Iterator { /// /// The elements can be floats but no particular result is guaranteed /// if an element is NaN. - #[cfg(feature = "use_std")] + #[cfg(feature = "use_alloc")] fn min_set_by(self, mut compare: F) -> Vec where Self: Sized, @@ -3234,7 +3234,7 @@ pub trait Itertools: Iterator { /// /// The elements can be floats but no particular result is guaranteed /// if an element is NaN. - #[cfg(feature = "use_std")] + #[cfg(feature = "use_alloc")] fn min_set_by_key(self, key: F) -> Vec where Self: Sized, @@ -3266,7 +3266,7 @@ pub trait Itertools: Iterator { /// /// The elements can be floats but no particular result is guaranteed /// if an element is NaN. - #[cfg(feature = "use_std")] + #[cfg(feature = "use_alloc")] fn max_set(self) -> Vec where Self: Sized, @@ -3299,7 +3299,7 @@ pub trait Itertools: Iterator { /// /// The elements can be floats but no particular result is guaranteed /// if an element is NaN. - #[cfg(feature = "use_std")] + #[cfg(feature = "use_alloc")] fn max_set_by(self, mut compare: F) -> Vec where Self: Sized, @@ -3331,7 +3331,7 @@ pub trait Itertools: Iterator { /// /// The elements can be floats but no particular result is guaranteed /// if an element is NaN. - #[cfg(feature = "use_std")] + #[cfg(feature = "use_alloc")] fn max_set_by_key(self, key: F) -> Vec where Self: Sized,