Implement an ersatz hash() for RSAIdentity

For whatever reason, something I had didn't like me implementing a
custom PartialEq but deriving Hash
This commit is contained in:
Nick Mathewson 2020-08-28 18:16:56 -04:00
parent 4b75c51882
commit 790d6becf2
1 changed files with 7 additions and 1 deletions

View File

@ -19,7 +19,7 @@ pub const RSA_ID_LEN: usize = 20;
/// An identifier for a Tor relay, based on its legacy RSA
/// identity key. These are used all over the Tor protocol.
#[derive(Clone, Zeroize, Debug, Hash)]
#[derive(Clone, Zeroize, Debug)]
pub struct RSAIdentity {
id: [u8; RSA_ID_LEN],
}
@ -30,6 +30,12 @@ impl PartialEq<RSAIdentity> for RSAIdentity {
}
}
impl std::hash::Hash for RSAIdentity {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.id.hash(state);
}
}
impl Eq for RSAIdentity {}
impl RSAIdentity {