Skip to content

Commit 3049c29

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

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

src/grouping_map.rs

+4-2
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

+4-6
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")]
@@ -3272,11 +3272,10 @@ pub trait Itertools: Iterator {
32723272
///
32733273
/// See [`GroupingMap`] for more informations
32743274
/// on what operations are available.
3275-
#[cfg(feature = "use_std")]
3275+
#[cfg(feature = "use_alloc")]
32763276
fn into_grouping_map<K, V>(self) -> GroupingMap<Self>
32773277
where
32783278
Self: Iterator<Item = (K, V)> + Sized,
3279-
K: Hash + Eq,
32803279
{
32813280
grouping_map::new(self)
32823281
}
@@ -3289,11 +3288,10 @@ pub trait Itertools: Iterator {
32893288
///
32903289
/// See [`GroupingMap`] for more informations
32913290
/// on what operations are available.
3292-
#[cfg(feature = "use_std")]
3291+
#[cfg(feature = "use_alloc")]
32933292
fn into_grouping_map_by<K, V, F>(self, key_mapper: F) -> GroupingMapBy<Self, F>
32943293
where
32953294
Self: Iterator<Item = V> + Sized,
3296-
K: Hash + Eq,
32973295
F: FnMut(&V) -> K,
32983296
{
32993297
grouping_map::new(grouping_map::new_map_for_grouping(self, key_mapper))

0 commit comments

Comments
 (0)