From 90203dd4671268c9e4fc09ecafd095d803013a07 Mon Sep 17 00:00:00 2001 From: Jiahao XU <Jiahao_XU@outlook.com> Date: Wed, 27 Jul 2022 20:33:40 +1000 Subject: [PATCH] Impl `PartialOrd` and `Ord` for `MetaData` Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> --- src/metafiles/binstall_v1.rs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/metafiles/binstall_v1.rs b/src/metafiles/binstall_v1.rs index a9cb446f..8ce59a4a 100644 --- a/src/metafiles/binstall_v1.rs +++ b/src/metafiles/binstall_v1.rs @@ -1,5 +1,5 @@ use std::{ - fs, hash, + cmp, fs, hash, io::{self, Write}, iter::IntoIterator, path::{Path, PathBuf}, @@ -24,12 +24,24 @@ pub struct MetaData { pub bins: Vec<CompactString>, } impl PartialEq for MetaData { - fn eq(&self, other: &MetaData) -> bool { + fn eq(&self, other: &Self) -> bool { self.name == other.name } } impl Eq for MetaData {} +impl PartialOrd for MetaData { + fn partial_cmp(&self, other: &Self) -> Option<cmp::Ordering> { + self.name.partial_cmp(&other.name) + } +} + +impl Ord for MetaData { + fn cmp(&self, other: &Self) -> cmp::Ordering { + self.name.cmp(&other.name) + } +} + impl hash::Hash for MetaData { fn hash<H>(&self, state: &mut H) where