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 #[inline] for Uuid::from_bytes[_ref] and Uuid::{as,into}_bytes #693

Merged
merged 1 commit into from Jul 16, 2023
Merged
Show file tree
Hide file tree
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
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