pub struct NonNilUuid(/* private fields */);
Expand description
A UUID that is guaranteed not to be the nil UUID.
This is useful for representing optional UUIDs more efficiently, as Option<NonNilUuid>
takes up the same space as Uuid
.
Note that Uuid
s created by the following methods are guaranteed to be non-nil:
- [
Uuid::new_v1
] - [
Uuid::now_v1
] - [
Uuid::new_v3
] Uuid::new_v4
- [
Uuid::new_v5
] - [
Uuid::new_v6
] - [
Uuid::now_v6
] - [
Uuid::new_v7
] - [
Uuid::now_v7
] - [
Uuid::new_v8
]
§ABI
The NonNilUuid
type does not yet have a stable ABI. Its representation or alignment
may change. It is currently only guaranteed that NonNilUuid
and Option<NonNilUuid>
are the same size as Uuid
.
Implementations§
source§impl NonNilUuid
impl NonNilUuid
sourcepub const unsafe fn new_unchecked(uuid: Uuid) -> Self
pub const unsafe fn new_unchecked(uuid: Uuid) -> Self
Creates a non-nil without checking whether the value is non-nil. This results in undefined behavior if the value is nil.
§Safety
The value must not be nil.
Trait Implementations§
source§impl Clone for NonNilUuid
impl Clone for NonNilUuid
source§fn clone(&self) -> NonNilUuid
fn clone(&self) -> NonNilUuid
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for NonNilUuid
impl Debug for NonNilUuid
source§impl<'de> Deserialize<'de> for NonNilUuid
impl<'de> Deserialize<'de> for NonNilUuid
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for NonNilUuid
impl Display for NonNilUuid
source§impl From<NonNilUuid> for Uuid
impl From<NonNilUuid> for Uuid
source§fn from(non_nil: NonNilUuid) -> Self
fn from(non_nil: NonNilUuid) -> Self
Converts a NonNilUuid
back into a Uuid
.
§Examples
let uuid = Uuid::from_u128(0x0123456789abcdef0123456789abcdef);
let non_nil = NonNilUuid::try_from(uuid).unwrap();
let uuid_again = Uuid::from(non_nil);
assert_eq!(uuid, uuid_again);
source§impl Hash for NonNilUuid
impl Hash for NonNilUuid
source§impl PartialEq<NonNilUuid> for Uuid
impl PartialEq<NonNilUuid> for Uuid
source§impl PartialEq<Uuid> for NonNilUuid
impl PartialEq<Uuid> for NonNilUuid
source§impl PartialEq for NonNilUuid
impl PartialEq for NonNilUuid
source§impl Serialize for NonNilUuid
impl Serialize for NonNilUuid
source§impl TryFrom<Uuid> for NonNilUuid
impl TryFrom<Uuid> for NonNilUuid
impl Copy for NonNilUuid
impl Eq for NonNilUuid
impl StructuralPartialEq for NonNilUuid
Auto Trait Implementations§
impl Freeze for NonNilUuid
impl RefUnwindSafe for NonNilUuid
impl Send for NonNilUuid
impl Sync for NonNilUuid
impl Unpin for NonNilUuid
impl UnwindSafe for NonNilUuid
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)