Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I'm submitting a(n) refactor
Description
#447 changed from using
rand::thread_rng
to usinggetrandom
inUuid::new_v4
. This also changed the return type fromUuid
toResult<Uuid, getrandom::Error>
. This PR reverts the signature to the simplernew_v4() -> Uuid
.Motivation
This signature is much simpler to use, and avoids a breaking change.
getrandom
is highly unlikely to fail, and previously we usedthread_rng
here, which also panics if it fails to initialize from the OS entropy source. Ifgetrandom
fails, it is highly unlikely that any program creating v4 UUIDs has any reasonable recovery other than to abort, as the system is in a broken state.If users absolutely need to recover in this situation, they can call
getrandom
first themselves to make sure that their system is working, or generate the bytes themselves and create the UUID from those bytes.Additionally, actually wrapping
getrandom::Error
inuuid::Error
comes with its own fun set of problems, described in #502.Tests
N/A
Related Issue(s)
#475: this undoes the breaking change to
Uuid::new_v4
, thus making the requested publish a patch updateCloses #502: alternate approach to the same TODO