From 317d925536a82ec5ca1cf9fdf8c6f91203bce8b8 Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Wed, 12 Jul 2023 10:27:15 -0700 Subject: [PATCH] Add #[inline] for Uuid::from_bytes[_ref] and Uuid::{as,into}_bytes --- src/builder.rs | 2 ++ src/lib.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/builder.rs b/src/builder.rs index 60aeb435..403ce1da 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -412,6 +412,7 @@ impl Uuid { /// # Ok(()) /// # } /// ``` + #[inline] pub const fn from_bytes(bytes: Bytes) -> Uuid { Uuid(bytes) } @@ -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) } diff --git a/src/lib.rs b/src/lib.rs index aea15530..2eebdf73 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -778,6 +778,7 @@ impl Uuid { /// &bytes1 as *const [u8; 16] as *const u8, /// )); /// ``` + #[inline] pub const fn as_bytes(&self) -> &Bytes { &self.0 } @@ -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 }