Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More generic maps in GroupingMap (v2) #906

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Commits on Mar 19, 2024

  1. Generic container: new Map private trait

    Note: `BTreeMap::remove<Q>` and `BTreeMap::remove<Q>` both accept a more general `Q` rather than just `Self::Key`.
    If ever needed, `Map<Q>` would be possible (with the same bound on `Q` than `Self::Key`: `Ord` or `Eq + Hash`).
    
    Implement `Map` for simple unordered `Vec<(_, _)>`. Note it uses `swap_remove`.
    Philippe-Cholet committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    87de8b6 View commit details
    Browse the repository at this point in the history
  2. Transform GroupingMap[By] into GroupingGenericMap[By]

    This is a huge but quite straightforward transformation:
    - `GroupingMap[By]` becomes `GroupingGenericMap[By]` with a generic type `M`
    - `K: Hash` becomes `M: Map<Key = K>`
    - `HashMap<K, ...>` becomes `M` with a `M: Map<Value = ...>` bound
    - Remove `Hash` and `HashMap`
    - `use_std` becomes `use_alloc`
    Philippe-Cholet committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    14b6096 View commit details
    Browse the repository at this point in the history
  3. Reintroduce GroupingMap[By] with one more generic parameter

    This is a breaking change! However, this is mostly inferred.
    Note that it breaks (only) laziness tests because the `GroupingMap` object is not used (I could write any type but `u8` is one of the possible returned types). If it was used then it would have been inferred.
    
    I copied/pasted the code of old `into_grouping_map[_by]` methods, added the generic `R` and updated each function body with `_in(.., HashMap::new())`.
    The old types are aliases of the new ones.
    Philippe-Cholet committed Mar 19, 2024
    Configuration menu
    Copy the full SHA
    dc15e5c View commit details
    Browse the repository at this point in the history

Commits on Mar 21, 2024

  1. Map::aggregate

    rust-itertools#901 (comment)
    SkiFire13 had the idea this could be optimized for vectors.
    Philippe-Cholet committed Mar 21, 2024
    Configuration menu
    Copy the full SHA
    2203cb6 View commit details
    Browse the repository at this point in the history