Add HashMapEntry
and BTreeMapEntry
aliases to std::collections
#340
Labels
HashMapEntry
and BTreeMapEntry
aliases to std::collections
#340
Proposal: in
std::collections
add{Hash,BTree}MapEntry
as an alias for{hash,btree}_map::Entry
Problem statement
Has this happened to you?
Motivating examples or use cases
It surely has happened to:
BTreeMapEntry
too)Not to mention that most of the contents in
std::colections::{hash,btree}_map
are "internal" things like iterator implementations, which you rarely ever have to refer to directly. Unlike withEntry
, which is a surprisingly versatility API that lends itself especially well with Rust's pattern matching. But then you have to name the type, and generally you have the following options:use std::collections::hash_map;
and then refer to it ashash_map::Entry
. But importing an entire module just to refer to a single type inside doesn't sit right with me.use std::collections::hash_map::Entry;
. Suboptimal, the name is too vague and might collide.use std::collections::hash_map::Entry as HashMapEntry;
Solution sketch
Add these two lines (plus the neccessary attributes) to
alloc/collections/mod.rs
&srd/collections/mod.rs
:Sadly, this is a breaking change because of the glob imports. But I guess this can be done across an edition boundary?
Alternatives
type HashMapEntry<'a, K, V, A = Global> = hash_map::Entry<'a, K, V, A>;
(sounds even worse).The text was updated successfully, but these errors were encountered: