Skip to content

Commit

Permalink
grouping_map module behind use_alloc feature
Browse files Browse the repository at this point in the history
Relax `K: Hash + Eq` bounds to soon accept `BTreeMap<K, V>`.
  • Loading branch information
Philippe-Cholet committed Mar 12, 2024
1 parent d43c3cc commit 3049c29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 4 additions & 2 deletions src/grouping_map.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -41,7 +43,6 @@ pub(crate) fn new_map_for_grouping<K, I: Iterator, F: FnMut(&I::Item) -> K>(
pub fn new<I, K, V>(iter: I) -> GroupingMap<I>
where
I: Iterator<Item = (K, V)>,
K: Hash + Eq,
{
GroupingMap { iter }
}
Expand All @@ -62,6 +63,7 @@ pub struct GroupingMap<I> {
iter: I,
}

#[cfg(feature = "use_std")]
impl<I, K, V> GroupingMap<I>
where
I: Iterator<Item = (K, V)>,
Expand Down
10 changes: 4 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -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")]
Expand Down Expand Up @@ -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<K, V>(self) -> GroupingMap<Self>
where
Self: Iterator<Item = (K, V)> + Sized,
K: Hash + Eq,
{
grouping_map::new(self)
}
Expand All @@ -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<K, V, F>(self, key_mapper: F) -> GroupingMapBy<Self, F>
where
Self: Iterator<Item = V> + Sized,
K: Hash + Eq,
F: FnMut(&V) -> K,
{
grouping_map::new(grouping_map::new_map_for_grouping(self, key_mapper))
Expand Down

0 comments on commit 3049c29

Please sign in to comment.