Impl PartialOrd and Ord for MetaData

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2022-07-27 20:33:40 +10:00
parent 4114b6e7c4
commit 90203dd467
No known key found for this signature in database
GPG key ID: 591C0B03040416D6

View file

@ -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