Variant can never be None #459
Labels
No labels
breaking
bug
dependencies
good first issue
help wanted
unstable
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-uuid-rs/uuid#459
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The
variantcurrently returns anOptionaland has aNonebranch, however, this branch is actually unreachable. As a reminder, here is what the RFC has to say about the variant:— RFC 4122: 4.1.1. Variant
What we can derive from this (and is correctly coded in the library) is:
0is NCS, regardless of what comes next.10is RFC, regardless of what comes next.110is always MS, and111is always future.There is no combination possible that would lead no variant being present, regardless of the contents of the UUID value.
I created a playground snippet to proof it, just in case the theory is not enough.
The
Optionalshould be removed and eitherVariant.Futureis returned in the last match arm orunreachable!is used. The doc of the function should be extended to explain this and warn users that they should only trust the variant if the UUID they are dealing with comes from a trusted source (this is actually true for any UUID introspection since it‘s just random data after all).Thanks @Fleshgrinder! I’ve updated the
get_variantmethod so that it’s now infallible.