summaryrefslogtreecommitdiffstats
path: root/lib/entry/libimagentrylink
diff options
context:
space:
mode:
authorflip1995 <hello@philkrones.com>2019-07-26 22:52:02 +0200
committerMatthias Beyer <mail@beyermatthias.de>2019-07-26 23:05:09 +0200
commit2c26fd27531ec61299c7a4e15cee64c88316242e (patch)
treec40594ad9315989cee3cd22e9a88327287e1eb7e /lib/entry/libimagentrylink
parent6ac6db57d11eeb2393fe0771db630899e9ea326c (diff)
Fix Hash vs PartialEq bug found by Clippy
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
Diffstat (limited to 'lib/entry/libimagentrylink')
-rw-r--r--lib/entry/libimagentrylink/src/link.rs13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/entry/libimagentrylink/src/link.rs b/lib/entry/libimagentrylink/src/link.rs
index f12698be..5462256c 100644
--- a/lib/entry/libimagentrylink/src/link.rs
+++ b/lib/entry/libimagentrylink/src/link.rs
@@ -27,7 +27,7 @@ use failure::ResultExt;
use failure::Fallible as Result;
use failure::Error;
-#[derive(Eq, PartialOrd, Ord, Hash, Debug, Clone)]
+#[derive(Eq, PartialOrd, Ord, Debug, Clone)]
pub enum Link {
Id { 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 {
fn from(s: StoreId) -> Link {