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(&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 for Link { fn from(s: StoreId) -> Link {