From 4114b6e7c4bc8a05b5db98d0b3cd8d34a9ad2f80 Mon Sep 17 00:00:00 2001 From: Jiahao XU Date: Wed, 27 Jul 2022 20:19:05 +1000 Subject: [PATCH] Impl `PartialEq`, `Eq` and `Hash` fo `MetaData` Signed-off-by: Jiahao XU --- src/metafiles/binstall_v1.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/metafiles/binstall_v1.rs b/src/metafiles/binstall_v1.rs index 475e1274..a9cb446f 100644 --- a/src/metafiles/binstall_v1.rs +++ b/src/metafiles/binstall_v1.rs @@ -1,5 +1,5 @@ use std::{ - fs, + fs, hash, io::{self, Write}, iter::IntoIterator, path::{Path, PathBuf}, @@ -23,6 +23,21 @@ pub struct MetaData { pub target: CompactString, pub bins: Vec, } +impl PartialEq for MetaData { + fn eq(&self, other: &MetaData) -> bool { + self.name == other.name + } +} +impl Eq for MetaData {} + +impl hash::Hash for MetaData { + fn hash(&self, state: &mut H) + where + H: hash::Hasher, + { + self.name.hash(state) + } +} #[derive(Debug, Copy, Clone, Serialize, Deserialize)] pub enum SourceType {