Skip to content
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

Add Uuid::into_bytes(self) #584

Merged
merged 2 commits into from Feb 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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