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 fn new(uuid: Uuid) -> Option<NonNilUuid>
pub const fn new(uuid: Uuid) -> Option<NonNilUuid>
Creates a non-nil UUID if the value is non-nil.
Sourcepub const unsafe fn new_unchecked(uuid: Uuid) -> NonNilUuid
pub const unsafe fn new_unchecked(uuid: Uuid) -> NonNilUuid
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 duplicate 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 Display for NonNilUuid
impl Display for NonNilUuid
Sourceยงimpl From<NonNilUuid> for Uuid
impl From<NonNilUuid> for Uuid
Sourceยงfn from(non_nil: NonNilUuid) -> Uuid
fn from(non_nil: NonNilUuid) -> Uuid
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 TryFrom<Uuid> for NonNilUuid
impl TryFrom<Uuid> for NonNilUuid
Sourceยงfn try_from(
uuid: Uuid,
) -> Result<NonNilUuid, <NonNilUuid as TryFrom<Uuid>>::Error>
fn try_from( uuid: Uuid, ) -> Result<NonNilUuid, <NonNilUuid as TryFrom<Uuid>>::Error>
Attempts to convert a Uuid
into a NonNilUuid
.
ยงExamples
let uuid = Uuid::from_u128(0x0123456789abcdef0123456789abcdef);
let non_nil = NonNilUuid::try_from(uuid).unwrap();
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ยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงimpl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Sourceยงfn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.Sourceยงimpl<T> IntoEither for T
impl<T> IntoEither for T
Sourceยงfn into_either(self, into_left: bool) -> Either<Self, Self> โ
fn into_either(self, into_left: bool) -> Either<Self, Self> โ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSourceยงfn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more