-
Notifications
You must be signed in to change notification settings - Fork 194
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
Generate v5 & v3 UUIDs from Values that Implement Hash
#623
Comments
Hi @azdle 👋 This is a great suggestion 👍 I'd consider loosening that bound to be a minor change (the old API evolution RFC thinks so too). You're right that inference would break, like in this example: let uuid = Uuid::new_v5(ns, name.as_ref()); but I think that's ok. These aren't really widely used methods and the proposed signature is better. |
The ideal signature would probably simply be: fn new_v5(namespace: &Uuid, name: impl Hash) -> Uuid |
I looked into this, and it's unfortunately not as straight-forward as you'd hope. The standard I think the best approach for now will be to add some examples to the project that show how you can convert something that implements |
Just coming back through some triage. It looks like as nice as this would be a to do, we probably can't in a non-breaking way, so I'll go ahead and close this one for now. We might be able to revisit it in the future if things change. |
Motivation
I've got a few different things that are shaped like https://doc.rust-lang.org/std/thread/struct.ThreadId.html, opaque identifiers that wrap a
u64
, that I'm using to generate reproducible unique IDs by name-spacing them withnew_v5
. These all implement Hash, it would be nice if I could just hand them tonew_v5
or a5v_from_hash
or something.Solution
I believe
new_v5
andnew_v3
could be changed from their currentto something like
Alternatives
I'm unsure if that could be a breaking change with how coercion are handled. If it is, new separate functions could be created instead.
Is it blocking?
Nope, I have a gross thing to extract the raw IDs for now, but it would be nice to not have to do that.
The text was updated successfully, but these errors were encountered: