From 3049c291884de711a0e3f170bbd696311b2a9020 Mon Sep 17 00:00:00 2001 From: Philippe-Cholet <44676486+Philippe-Cholet@users.noreply.github.com> Date: Tue, 12 Mar 2024 10:56:17 +0100 Subject: [PATCH] `grouping_map` module behind `use_alloc` feature Relax `K: Hash + Eq` bounds to soon accept `BTreeMap`. --- src/grouping_map.rs | 6 ++++-- src/lib.rs | 10 ++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/grouping_map.rs b/src/grouping_map.rs index 47a7c096e..de066042d 100644 --- a/src/grouping_map.rs +++ b/src/grouping_map.rs @@ -1,11 +1,13 @@ -#![cfg(feature = "use_std")] +#![cfg(feature = "use_alloc")] use crate::{ adaptors::map::{MapSpecialCase, MapSpecialCaseFn}, MinMaxResult, }; use std::cmp::Ordering; +#[cfg(feature = "use_std")] use std::collections::HashMap; +#[cfg(feature = "use_std")] use std::hash::Hash; use std::iter::Iterator; use std::ops::{Add, Mul}; @@ -41,7 +43,6 @@ pub(crate) fn new_map_for_grouping K>( pub fn new(iter: I) -> GroupingMap where I: Iterator, - K: Hash + Eq, { GroupingMap { iter } } @@ -62,6 +63,7 @@ pub struct GroupingMap { iter: I, } +#[cfg(feature = "use_std")] impl GroupingMap where I: Iterator, diff --git a/src/lib.rs b/src/lib.rs index 07fcf61c1..8ce9fadcd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -106,7 +106,7 @@ pub mod structs { pub use crate::groupbylazy::GroupBy; #[cfg(feature = "use_alloc")] pub use crate::groupbylazy::{Chunk, ChunkBy, Chunks, Group, Groups, IntoChunks}; - #[cfg(feature = "use_std")] + #[cfg(feature = "use_alloc")] pub use crate::grouping_map::{GroupingMap, GroupingMapBy}; pub use crate::intersperse::{Intersperse, IntersperseWith}; #[cfg(feature = "use_alloc")] @@ -191,7 +191,7 @@ mod generic_containers; mod group_map; #[cfg(feature = "use_alloc")] mod groupbylazy; -#[cfg(feature = "use_std")] +#[cfg(feature = "use_alloc")] mod grouping_map; mod intersperse; #[cfg(feature = "use_alloc")] @@ -3272,11 +3272,10 @@ pub trait Itertools: Iterator { /// /// See [`GroupingMap`] for more informations /// on what operations are available. - #[cfg(feature = "use_std")] + #[cfg(feature = "use_alloc")] fn into_grouping_map(self) -> GroupingMap where Self: Iterator + Sized, - K: Hash + Eq, { grouping_map::new(self) } @@ -3289,11 +3288,10 @@ pub trait Itertools: Iterator { /// /// See [`GroupingMap`] for more informations /// on what operations are available. - #[cfg(feature = "use_std")] + #[cfg(feature = "use_alloc")] fn into_grouping_map_by(self, key_mapper: F) -> GroupingMapBy where Self: Iterator + Sized, - K: Hash + Eq, F: FnMut(&V) -> K, { grouping_map::new(grouping_map::new_map_for_grouping(self, key_mapper))