-
Notifications
You must be signed in to change notification settings - Fork 195
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
NonZeroUuid #770
Comments
Hi @rick-de-water 👋 A UUID with all zeroes is actually a valid value, it’s called the nil UUID. Are you looking at |
Of course, and an integer with a value of zero is also valid. There are however situation where you know that you will never use that value, and you can allow the compiler to do niche optimization if you inform it. This is what happens with the Its actually quite common to have domain models that do not have NIL UUIDs, since they get generated at the moment of creation and never change. Having |
This commit introduces a new `NonZeroUuid` type that wraps a `Uuid` and guarantees that it is not the nil UUID. This allows for a more memory-efficient representation of `Option<Uuid>`, as `Option<NonZeroUuid>` takes up the same space as `Uuid`. This change improves the memory efficiency of representing optional UUIDs and provides a more convenient way to work with non-nil UUIDs. fixes: uuid-rs#770
Is there a
NonZeroUuid
type, or has one been considered, similar to the otherNonZero
types, such that the following is true?The text was updated successfully, but these errors were encountered: