You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to use ksuid within an HashMap<Ksuid/KsuidMs, T> and I would prefer not to convert to a string, i.e. HashMap<String, T>.
Right now I am wrapping it within a struct (I am not aware of a better way, like a macro to implicitly call to_string before hashing):
use std::hash::{Hash,Hasher};use svix_ksuid::Ksuid;pubstructId(pubKsuid);implHashforId{fnhash<H:Hasher>(&self,state:&mutH){self.0.to_string().hash(state);}}
Proposal
I believe the following would be enough:
use std::hash::{Hash,Hasher};implHashforKsuid{fnhash<H:Hasher>(&self,state:&mutH){self.to_string().hash(state);}}implHashforKsuidMs{fnhash<H:Hasher>(&self,state:&mutH){self.to_string().hash(state);}}
Pros:
simple
not prone to bugs or hash collisions (not more than ksuid as far as my understanding)
Alternatives
Having an intermediate String before computing the hash is not the most efficient way to do this but I personally would prefer to have something even if it is not the most performant 😇
Next
If you don't mind my proposal, would you like me to make a PR with it?
If you do mind adding this, fair enough, I will handle this on my end. 😉
If you do mind using the intermediate string, do you already have in mind a way to do it or would you like me to look into it? (my experience is limited)
Either way, thank you for the library 😄
The text was updated successfully, but these errors were encountered:
Feature Request
Motivation
I would like to use
ksuid
within anHashMap<Ksuid/KsuidMs, T>
and I would prefer not to convert to a string, i.e.HashMap<String, T>
.Right now I am wrapping it within a struct (I am not aware of a better way, like a macro to implicitly call
to_string
before hashing):Proposal
I believe the following would be enough:
Pros:
Alternatives
Having an intermediate String before computing the hash is not the most efficient way to do this but I personally would prefer to have something even if it is not the most performant 😇
Next
If you don't mind my proposal, would you like me to make a PR with it?
If you do mind adding this, fair enough, I will handle this on my end. 😉
If you do mind using the intermediate string, do you already have in mind a way to do it or would you like me to look into it? (my experience is limited)
Either way, thank you for the library 😄
The text was updated successfully, but these errors were encountered: