Add Uuid::into_bytes(self)

Fixes #580
This commit is contained in:
A248 2022-02-06 16:09:04 -05:00
parent f362fa8b88
commit bb409b369f
No known key found for this signature in database
GPG Key ID: 8834507958FD2A31

View File

@ -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.clone());
/// 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