diff --git a/uefi/CHANGELOG.md b/uefi/CHANGELOG.md index 132d2dc6e..eb7098ceb 100644 --- a/uefi/CHANGELOG.md +++ b/uefi/CHANGELOG.md @@ -5,6 +5,7 @@ - Added `CStr16::from_char16_with_nul` and `Char16::from_char16_with_nul_unchecked`. - Added terminal GUID constants to `device_path::messaging::Vendor`. - Added `MemoryMap::from_raw`. +- Implemented `Hash` for all char and string types. ## Changed - `DevicePath::to_string` and `DevicePathNode::to_string` now return diff --git a/uefi/src/data_types/chars.rs b/uefi/src/data_types/chars.rs index 96cd00813..7d3b9a368 100644 --- a/uefi/src/data_types/chars.rs +++ b/uefi/src/data_types/chars.rs @@ -19,7 +19,7 @@ impl Display for CharConversionError { impl core::error::Error for CharConversionError {} /// A Latin-1 character -#[derive(Clone, Copy, Default, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Default, Eq, PartialEq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct Char8(u8); @@ -76,7 +76,7 @@ impl PartialEq for Char8 { pub const NUL_8: Char8 = Char8(0); /// An UCS-2 code point -#[derive(Clone, Copy, Default, Eq, PartialEq, PartialOrd, Ord)] +#[derive(Clone, Copy, Default, Eq, PartialEq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct Char16(u16); diff --git a/uefi/src/data_types/owned_strs.rs b/uefi/src/data_types/owned_strs.rs index 8e673c2f2..cf11f43ae 100644 --- a/uefi/src/data_types/owned_strs.rs +++ b/uefi/src/data_types/owned_strs.rs @@ -50,7 +50,7 @@ impl core::error::Error for FromStrError {} /// let s = CString16::try_from("abc").unwrap(); /// assert_eq!(s.to_string(), "abc"); /// ``` -#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd)] +#[derive(Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct CString16(Vec); impl CString16 { diff --git a/uefi/src/data_types/strs.rs b/uefi/src/data_types/strs.rs index f9d4aabfa..449d0e404 100644 --- a/uefi/src/data_types/strs.rs +++ b/uefi/src/data_types/strs.rs @@ -109,7 +109,7 @@ impl core::error::Error for FromStrWithBufError {} /// For convenience, a [`CStr8`] is comparable with [`core::str`] and /// `alloc::string::String` from the standard library through the trait [`EqStrUntilNul`]. #[repr(transparent)] -#[derive(Eq, PartialEq, Ord, PartialOrd)] +#[derive(Eq, PartialEq, Ord, PartialOrd, Hash)] pub struct CStr8([Char8]); impl CStr8 { @@ -230,7 +230,7 @@ impl<'a> TryFrom<&'a CStr> for &'a CStr8 { /// /// For convenience, a [`CStr16`] is comparable with [`core::str`] and /// `alloc::string::String` from the standard library through the trait [`EqStrUntilNul`]. -#[derive(Eq, PartialEq, Ord, PartialOrd)] +#[derive(Eq, PartialEq, Ord, PartialOrd, Hash)] #[repr(transparent)] pub struct CStr16([Char16]);