Skip to content

Commit 4331f41

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

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/grouping_map.rs

Lines changed: 4 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,6 @@ 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,
4546
{
4647
GroupingMap { iter }
4748
}
@@ -62,6 +63,7 @@ pub struct GroupingMap<I> {
6263
iter: I,
6364
}
6465

66+
#[cfg(feature = "use_std")]
6567
impl<I, K, V> GroupingMap<I>
6668
where
6769
I: Iterator<Item = (K, V)>,

src/lib.rs

Lines changed: 4 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,10 @@ 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,
32913290
{
32923291
grouping_map::new(self)
32933292
}
@@ -3300,11 +3299,10 @@ pub trait Itertools: Iterator {
33003299
///
33013300
/// See [`GroupingMap`] for more informations
33023301
/// on what operations are available.
3303-
#[cfg(feature = "use_std")]
3302+
#[cfg(feature = "use_alloc")]
33043303
fn into_grouping_map_by<K, V, F>(self, key_mapper: F) -> GroupingMapBy<Self, F>
33053304
where
33063305
Self: Iterator<Item = V> + Sized,
3307-
K: Hash + Eq,
33083306
F: FnMut(&V) -> K,
33093307
{
33103308
grouping_map::new(grouping_map::new_map_for_grouping(self, key_mapper))

0 commit comments

Comments
 (0)