-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
HashSet should have a get function #691
Comments
I would love to see this feature also. It is necessary for object canonicalization. |
I have this on the maps and sets in rust-phf since the |
I think this was covered by #1194. |
@steveklabnik Do you think this can be closed? |
Implemented in rust-lang/rust#28043. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue by Noctune
Friday Jan 16, 2015 at 13:10 GMT
For earlier discussion, see rust-lang/rust#21234
This issue was labelled with: A-collections, A-libs in the Rust repository
I think
HashSet
should have aget
function likeHashMap
has, as equality does not necessarily mean that two elements are identical.The reason I think this is necessary is that I'm trying to create a voxel world (think Minecraft) that is split into 3D chunks. Many of these chunks are identical (a lot of it is just air, for example), so it would make sense to reuse the a chunk in several places. When a new chunk is generated, the hash of the chunk is looked up in a collection to see if there is an already identical chunk and if there is, then use that one.
If
HashSet
had aget
function then I could use aHashSet<Arc<Chunk>>
, but since it does not, I instead have to use aHashMap<Arc<Chunk>, Arc<Chunk>>
where the key and value is always the same which does not seem totally logical and downright impossible if it were a non-cloneable key.Likewise, it may be an idea to implement some sort of
get_key_value
that would return a key value pair forHashMap
.The text was updated successfully, but these errors were encountered: