More generic maps in GroupingMap
(v2)
#906
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This an alternative to #901 that I learnt from, it would close #901, close #588 and eventually solve most generic-containerGeneric vector/hasher/map
issues.
Map
polished earlier.GroupingMap[By]
intoGroupingGenericMap[By]
This is a huge but quite straightforward transformation:
GroupingMap[By]
becomesGroupingGenericMap[By]
with a generic typeM
K: Hash
becomesM: Map<Key = K>
HashMap<K, ...>
becomesM
with aM: Map<Value = ...>
boundHash
andHashMap
use_std
becomesuse_alloc
GroupingMap[By]
with one more generic parameterThis 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 butu8
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 genericR
and updated each function body with_in(.., HashMap::new())
.The old types are aliases of the new ones.
The main interest of this PR over #901 is that there is not
_in
versions for eachGroupingMap
method.More than the additional parameter, the following code (weird but currently working) would not compile anymore.
However, it's easily solvable here,
.into_grouping_map_by(|n| n % 2)
should be moved to both branches for the code to work as before.Now, in other cases, it might be not that easily solvable! Is it a too big breaking change?