Fix Hash vs PartialEq bug found by Clippy
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
parent
6ac6db57d1
commit
2c26fd2753
1 changed files with 12 additions and 1 deletions
|
@ -27,7 +27,7 @@ use failure::ResultExt;
|
||||||
use failure::Fallible as Result;
|
use failure::Fallible as Result;
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
|
|
||||||
#[derive(Eq, PartialOrd, Ord, Hash, Debug, Clone)]
|
#[derive(Eq, PartialOrd, Ord, Debug, Clone)]
|
||||||
pub enum Link {
|
pub enum Link {
|
||||||
Id { link: StoreId },
|
Id { link: StoreId },
|
||||||
LinkTo { link: StoreId },
|
LinkTo { link: StoreId },
|
||||||
|
@ -99,6 +99,17 @@ impl ::std::cmp::PartialEq for Link {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl std::hash::Hash for Link {
|
||||||
|
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||||
|
std::mem::discriminant(self).hash(state);
|
||||||
|
match &self {
|
||||||
|
Link::Id { link: a } => a.hash(state),
|
||||||
|
Link::LinkTo { link: a } => a.hash(state),
|
||||||
|
Link::LinkFrom { link: a } => a.hash(state),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<StoreId> for Link {
|
impl From<StoreId> for Link {
|
||||||
|
|
||||||
fn from(s: StoreId) -> Link {
|
fn from(s: StoreId) -> Link {
|
||||||
|
|
Loading…
Reference in a new issue