Skip to content

Commit

Permalink
Merge pull request rust-osdev#1086 from nicholasbishop/bishop-hash-str
Browse files Browse the repository at this point in the history
uefi: Derive Hash for all char and string types
  • Loading branch information
phip1611 authored Mar 13, 2024
2 parents 37170fc + 91a9f7c commit 34ddf7b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions uefi/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions uefi/src/data_types/chars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -76,7 +76,7 @@ impl PartialEq<char> 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);

Expand Down
2 changes: 1 addition & 1 deletion uefi/src/data_types/owned_strs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Char16>);

impl CString16 {
Expand Down
4 changes: 2 additions & 2 deletions uefi/src/data_types/strs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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]);

Expand Down

0 comments on commit 34ddf7b

Please sign in to comment.