diff --git a/CHANGELOG.md b/CHANGELOG.md index edcbb99..efe3fa7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,9 +5,13 @@ This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## Unreleased +### Added + +- Added `PartialEq` for `Vec` and `&[u8; 16]`. + ### Changed -- `from_bytes_ref`, `as_uuid` and `is_empty` are now `const`. +- `to_bytes_le`, `from_bytes_ref`, `as_uuid` and `is_empty` are now `const`. ### Internal diff --git a/src/lib.rs b/src/lib.rs index 96f2f77..fd9053a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -153,7 +153,7 @@ impl ShortGuid { /// # } /// ``` #[inline] - pub fn to_bytes_le(&self) -> [u8; 16] { + pub const fn to_bytes_le(&self) -> [u8; 16] { self.0.to_bytes_le() } @@ -281,12 +281,24 @@ impl PartialEq<&str> for ShortGuid { } } +impl PartialEq> for ShortGuid { + fn eq(&self, other: &Vec) -> bool { + other.len() == 16 && self.as_bytes().eq(other.as_slice()) + } +} + impl PartialEq<&[u8]> for ShortGuid { fn eq(&self, other: &&[u8]) -> bool { other.len() == 16 && self.as_bytes().eq(other) } } +impl PartialEq<&[u8; 16]> for ShortGuid { + fn eq(&self, other: &&[u8; 16]) -> bool { + self.as_bytes().eq(*other) + } +} + impl PartialEq<[u8; 16]> for ShortGuid { fn eq(&self, other: &[u8; 16]) -> bool { self.as_bytes().eq(other)