Skip to content

Commit

Permalink
Merge pull request #693 from jrose-signal/inline-from_bytes
Browse files Browse the repository at this point in the history
Add #[inline] for Uuid::from_bytes[_ref] and Uuid::{as,into}_bytes
  • Loading branch information
KodrAus authored Jul 16, 2023
2 parents bd7df72 + 317d925 commit 6b0cfb2
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,7 @@ impl Uuid {
/// &bytes1 as *const [u8; 16] as *const u8,
/// ));
/// ```
#[inline]
pub const fn as_bytes(&self) -> &Bytes {
&self.0
}
Expand All @@ -802,6 +803,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 6b0cfb2

Please sign in to comment.