Skip to content

Commit

Permalink
Merge pull request #743 from koshell/main
Browse files Browse the repository at this point in the history
impl AsRef<Uuid> for Uuid
  • Loading branch information
KodrAus authored Mar 18, 2024
2 parents 951e8e3 + 6b2a501 commit 9415ed4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,13 @@ impl Default for Uuid {
}
}

impl AsRef<Uuid> for Uuid {
#[inline]
fn as_ref(&self) -> &Uuid {
self
}
}

impl AsRef<[u8]> for Uuid {
#[inline]
fn as_ref(&self) -> &[u8] {
Expand Down Expand Up @@ -1745,7 +1752,7 @@ mod tests {
fn test_as_bytes() {
let u = new();
let ub = u.as_bytes();
let ur = u.as_ref();
let ur: &[u8] = u.as_ref();

assert_eq!(ub.len(), 16);
assert_eq!(ur.len(), 16);
Expand All @@ -1767,7 +1774,7 @@ mod tests {
use crate::std::{convert::TryInto, vec::Vec};

let u = new();
let ub = u.as_ref();
let ub: &[u8] = u.as_ref();

let v: Vec<u8> = u.into();

Expand Down

0 comments on commit 9415ed4

Please sign in to comment.