Skip to content

Commit

Permalink
Implement Hash for ByteOrder types
Browse files Browse the repository at this point in the history
The absence of these impls lead to the absence of `Hash` for the
byteorder-aware numeric types.

Fixes #1871
  • Loading branch information
jswrenn committed Oct 11, 2024
1 parent 35b07fe commit 06dde5f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/byteorder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
use core::{
convert::{TryFrom, TryInto},
fmt::{Binary, Debug, LowerHex, Octal, UpperHex},
hash::Hash,
num::TryFromIntError,
};

Expand All @@ -81,7 +82,7 @@ use super::*;
///
/// [`U32<BigEndian>`]: U32
pub trait ByteOrder:
Copy + Clone + Debug + Display + Eq + PartialEq + Ord + PartialOrd + private::Sealed
Copy + Clone + Debug + Display + Eq + PartialEq + Ord + PartialOrd + Hash + private::Sealed
{
#[doc(hidden)]
const ORDER: Order;
Expand All @@ -104,7 +105,7 @@ pub enum Order {
/// Big-endian byte order.
///
/// See [`ByteOrder`] for more details.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum BigEndian {}

impl ByteOrder for BigEndian {
Expand All @@ -121,7 +122,7 @@ impl Display for BigEndian {
/// Little-endian byte order.
///
/// See [`ByteOrder`] for more details.
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd)]
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, Hash)]
pub enum LittleEndian {}

impl ByteOrder for LittleEndian {
Expand Down

0 comments on commit 06dde5f

Please sign in to comment.