Skip to content

Commit

Permalink
Merge pull request #584 from A248/into-bytes
Browse files Browse the repository at this point in the history
Add Uuid::into_bytes(self)
  • Loading branch information
KodrAus committed Feb 10, 2022
2 parents f362fa8 + c41c6ce commit a1fd80c
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/lib.rs
Expand Up @@ -759,6 +759,25 @@ impl Uuid {
&self.0
}

/// Consumes self and returns the underlying byte value of the UUID.
///
/// # Examples
///
/// ```
/// # use uuid::Uuid;
/// let bytes = [
/// 0xa1, 0xa2, 0xa3, 0xa4,
/// 0xb1, 0xb2,
/// 0xc1, 0xc2,
/// 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8,
/// ];
/// let uuid = Uuid::from_bytes(bytes);
/// assert_eq!(bytes, uuid.into_bytes());
/// ```
pub const fn into_bytes(self) -> Bytes {
self.0
}

/// Tests if the UUID is nil.
pub const fn is_nil(&self) -> bool {
self.as_u128() == 0
Expand Down

0 comments on commit a1fd80c

Please sign in to comment.