Skip to content

Commit

Permalink
Impl Hash for IntAddr,VarAddr and StdAddr
Browse files Browse the repository at this point in the history
  • Loading branch information
Rexagon committed Nov 14, 2023
1 parent 7f2e3b4 commit cd47364
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/models/message/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::num::*;
use crate::util::*;

/// Internal message address.
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
#[derive(Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub enum IntAddr {
/// Standard internal address.
Std(StdAddr),
Expand Down Expand Up @@ -151,7 +151,7 @@ impl<'a> Load<'a> for IntAddr {
}

/// Standard internal address.
#[derive(Debug, Default, Clone, Eq, PartialEq, Ord, PartialOrd)]
#[derive(Debug, Default, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct StdAddr {
/// Optional anycast info.
pub anycast: Option<Box<Anycast>>,
Expand Down Expand Up @@ -345,7 +345,7 @@ impl crate::dict::DictKey for StdAddr {
}

/// Variable-length internal address.
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
#[derive(Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct VarAddr {
/// Optional anycast info.
pub anycast: Option<Box<Anycast>>,
Expand Down Expand Up @@ -416,7 +416,7 @@ impl Store for VarAddr {
/// addr_none$00 = MsgAddressExt;
/// addr_extern$01 len:(## 9) external_address:(bits len) = MsgAddressExt;
/// ```
#[derive(Debug, Default, Clone, Eq, PartialEq, Ord, PartialOrd)]
#[derive(Debug, Default, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct ExtAddr {
/// Number of bits stored in data.
pub data_bit_len: Uint9,
Expand Down Expand Up @@ -452,7 +452,7 @@ impl ExtAddr {
/// ```text
/// anycast_info$_ depth:(#<= 30) { depth >= 1 } rewrite_pfx:(bits depth) = Anycast;
/// ```
#[derive(Debug, Clone, Eq, PartialEq, Ord, PartialOrd)]
#[derive(Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct Anycast {
/// Prefix length in bits.
pub depth: SplitDepth,
Expand Down
8 changes: 4 additions & 4 deletions src/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ macro_rules! impl_var_uints {

(@impl $(#[doc = $doc:expr])* $vis:vis $ident:ident $inner:ty, $max_bytes:literal) => {
$(#[doc = $doc])*
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[repr(transparent)]
$vis struct $ident($inner);

Expand Down Expand Up @@ -480,7 +480,7 @@ impl<'a> Load<'a> for Tokens {
/// Variable-length 248-bit integer.
///
/// Stored as 5 bits of `len` (`0..=31`), followed by `len` bytes.
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq)]
#[repr(transparent)]
pub struct VarUint248([u128; 2]);

Expand Down Expand Up @@ -637,7 +637,7 @@ macro_rules! impl_small_uints {

(@impl $(#[doc = $doc:expr])* $vis:vis $ident:ident, $bits:literal) => {
$(#[doc = $doc])*
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
#[repr(transparent)]
$vis struct $ident(u16);

Expand Down Expand Up @@ -773,7 +773,7 @@ impl_small_uints! {
}

/// Account split depth. Fixed-length 5-bit integer of range `1..=30`
#[derive(Debug, Clone, Copy, Eq, PartialEq, Ord, PartialOrd)]
#[derive(Debug, Clone, Copy, Hash, Eq, PartialEq, Ord, PartialOrd)]
#[repr(transparent)]
pub struct SplitDepth(NonZeroU8);

Expand Down

0 comments on commit cd47364

Please sign in to comment.