Skip to content

Commit f6da436

Browse files
grouping_map module behind use_alloc feature
Relax `K: Hash + Eq` bounds to soon accept `BTreeMap<K, V>`.
1 parent ca064c8 commit f6da436

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/grouping_map.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
#![cfg(feature = "use_std")]
1+
#![cfg(feature = "use_alloc")]
22

33
use crate::{
44
adaptors::map::{MapSpecialCase, MapSpecialCaseFn},
55
MinMaxResult,
66
};
77
use std::cmp::Ordering;
8+
#[cfg(feature = "use_std")]
89
use std::collections::HashMap;
10+
#[cfg(feature = "use_std")]
911
use std::hash::Hash;
1012
use std::iter::Iterator;
1113
use std::ops::{Add, Mul};
@@ -41,7 +43,7 @@ pub(crate) fn new_map_for_grouping<K, I: Iterator, F: FnMut(&I::Item) -> K>(
4143
pub fn new<I, K, V>(iter: I) -> GroupingMap<I>
4244
where
4345
I: Iterator<Item = (K, V)>,
44-
K: Hash + Eq,
46+
K: Eq,
4547
{
4648
GroupingMap { iter }
4749
}
@@ -62,6 +64,7 @@ pub struct GroupingMap<I> {
6264
iter: I,
6365
}
6466

67+
#[cfg(feature = "use_std")]
6568
impl<I, K, V> GroupingMap<I>
6669
where
6770
I: Iterator<Item = (K, V)>,

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub mod structs {
106106
pub use crate::groupbylazy::GroupBy;
107107
#[cfg(feature = "use_alloc")]
108108
pub use crate::groupbylazy::{Chunk, ChunkBy, Chunks, Group, Groups, IntoChunks};
109-
#[cfg(feature = "use_std")]
109+
#[cfg(feature = "use_alloc")]
110110
pub use crate::grouping_map::{GroupingMap, GroupingMapBy};
111111
pub use crate::intersperse::{Intersperse, IntersperseWith};
112112
#[cfg(feature = "use_alloc")]
@@ -191,7 +191,7 @@ mod generic_containers;
191191
mod group_map;
192192
#[cfg(feature = "use_alloc")]
193193
mod groupbylazy;
194-
#[cfg(feature = "use_std")]
194+
#[cfg(feature = "use_alloc")]
195195
mod grouping_map;
196196
mod intersperse;
197197
#[cfg(feature = "use_alloc")]
@@ -3283,11 +3283,11 @@ pub trait Itertools: Iterator {
32833283
///
32843284
/// See [`GroupingMap`] for more informations
32853285
/// on what operations are available.
3286-
#[cfg(feature = "use_std")]
3286+
#[cfg(feature = "use_alloc")]
32873287
fn into_grouping_map<K, V>(self) -> GroupingMap<Self>
32883288
where
32893289
Self: Iterator<Item = (K, V)> + Sized,
3290-
K: Hash + Eq,
3290+
K: Eq,
32913291
{
32923292
grouping_map::new(self)
32933293
}
@@ -3300,11 +3300,11 @@ pub trait Itertools: Iterator {
33003300
///
33013301
/// See [`GroupingMap`] for more informations
33023302
/// on what operations are available.
3303-
#[cfg(feature = "use_std")]
3303+
#[cfg(feature = "use_alloc")]
33043304
fn into_grouping_map_by<K, V, F>(self, key_mapper: F) -> GroupingMapBy<Self, F>
33053305
where
33063306
Self: Iterator<Item = V> + Sized,
3307-
K: Hash + Eq,
3307+
K: Eq,
33083308
F: FnMut(&V) -> K,
33093309
{
33103310
grouping_map::new(grouping_map::new_map_for_grouping(self, key_mapper))

0 commit comments

Comments
 (0)