aboutsummaryrefslogtreecommitdiff
path: root/src/gentoo/package.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/gentoo/package.rs')
-rw-r--r--src/gentoo/package.rs24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/gentoo/package.rs b/src/gentoo/package.rs
index 1d41b8c..fcd86eb 100644
--- a/src/gentoo/package.rs
+++ b/src/gentoo/package.rs
@@ -4,12 +4,34 @@ use chrono::{DateTime, Utc};
use crate::gentoo::UseFlag;
-#[derive(Debug, Clone, Hash, Eq, PartialEq)]
+#[derive(Debug, Clone, Hash, Eq, PartialEq, Ord, PartialOrd)]
pub struct PackageKey {
+ // Field declaration matters because Ord, and PartialOrd check in order
pub category: String,
pub name: String,
}
+// impl Ord for PackageKey {
+// fn cmp(&self, other: &Self) -> std::cmp::Ordering {
+// let cat_ord = self.category.cmp(&other.category);
+// if cat_ord == Ordering::Equal {
+// return self.name.cmp(&other.name);
+// }
+//
+// cat_ord
+// }
+// }
+//
+// impl PartialOrd for PackageKey {
+// fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
+// match self.category.partial_cmp(&other.category) {
+// Some(core::cmp::Ordering::Equal) => {}
+// ord => return ord,
+// }
+// self.name.partial_cmp(&other.name)
+// }
+// }
+
impl PackageKey {
pub fn from_atom(s: &str) -> Option<Self> {
let (category, name) = s.split_once('/')?;