Skip to content

Commit

Permalink
Add #[inline] for Uuid::from_bytes[_ref] and Uuid::{as,into}_bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
jrose-signal committed Jul 12, 2023
1 parent 0fc3101 commit 317d925
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/builder.rs
Expand Up @@ -412,6 +412,7 @@ impl Uuid {
/// # Ok(())
/// # }
/// ```
#[inline]
pub const fn from_bytes(bytes: Bytes) -> Uuid {
Uuid(bytes)
}
Expand Down Expand Up @@ -480,6 +481,7 @@ impl Uuid {
/// # Ok(())
/// # }
/// ```
#[inline]
pub fn from_bytes_ref(bytes: &Bytes) -> &Uuid {
// SAFETY: `Bytes` and `Uuid` have the same ABI
unsafe { &*(bytes as *const Bytes as *const Uuid) }
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Expand Up @@ -778,6 +778,7 @@ impl Uuid {
/// &bytes1 as *const [u8; 16] as *const u8,
/// ));
/// ```
#[inline]
pub const fn as_bytes(&self) -> &Bytes {
&self.0
}
Expand All @@ -797,6 +798,7 @@ impl Uuid {
/// let uuid = Uuid::from_bytes(bytes);
/// assert_eq!(bytes, uuid.into_bytes());
/// ```
#[inline]
pub const fn into_bytes(self) -> Bytes {
self.0
}
Expand Down

0 comments on commit 317d925

Please sign in to comment.