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

Hash implementations #75

Closed
ghost opened this issue Jun 1, 2016 · 3 comments
Closed

Hash implementations #75

ghost opened this issue Jun 1, 2016 · 3 comments
Assignees

Comments

@ghost
Copy link

ghost commented Jun 1, 2016

It'd be nice to offer Hash implementations for all of the date/time structs so that they can be used as keys in HashMaps.

@lifthrasiir
Copy link
Contributor

lifthrasiir commented Jun 3, 2016

I think NaiveDate can be reasonably used as a hash key. For other types, uh, I don't think they work. Can I ask you for the use case? (And sorry for delay!)

@lifthrasiir lifthrasiir self-assigned this Jun 3, 2016
@ghost
Copy link
Author

ghost commented Jun 3, 2016

No problem! I didn't notice that NaiveDate worked; I was using Date<Local>. The main reason why it'd be nice to have is that I use Date<Local> and DateTime<Local> for all the times I parse from a user, and it seemed confusing that I need to call .naive_*() in order to use them as hash keys, because if I were to match the key, I'd have to re-cast them back into Locals, which might be ambiguous.

I think it'd be suitable if the Hash implementation just called .naive_date().hash() and ignored the time zone parts.

@pitdicker
Copy link
Collaborator

Fixed in #938.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants