summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-11-23 03:30:37 +0000
committerJohn Turner <jturner.usa@gmail.com>2025-11-23 03:30:37 +0000
commit5be1e5c37acb3d9d545a0e5b2992f0bf3148cc4e (patch)
tree5a10b6067940adda043eaef2ba4f84d877d282ff
parentf8149b43d463ec3248626fa2cba2ed6f8579bc47 (diff)
downloadgentoo-utils-5be1e5c37acb3d9d545a0e5b2992f0bf3148cc4e.tar.gz
derive Hash for Atom and similar types
-rw-r--r--src/atom/mod.rs50
-rw-r--r--src/useflag/mod.rs4
2 files changed, 29 insertions, 25 deletions
diff --git a/src/atom/mod.rs b/src/atom/mod.rs
index 73f6268..a483aaf 100644
--- a/src/atom/mod.rs
+++ b/src/atom/mod.rs
@@ -12,13 +12,13 @@ use itertools::Itertools;
mod parsers;
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum Blocker {
Weak,
Strong,
}
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum VersionOperator {
Lt,
Gt,
@@ -28,19 +28,20 @@ pub enum VersionOperator {
Roughly,
}
-#[derive(Clone, Debug, PartialEq, Eq, Get)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Get)]
pub struct Category(#[get(method = "get", kind = "deref")] String);
-#[derive(Clone, Debug, PartialEq, Eq, Get)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Get)]
pub struct Name(#[get(method = "get", kind = "deref")] String);
-#[derive(Clone, Debug, Get)]
+#[derive(Clone, Debug, Hash, Get)]
pub struct VersionNumber(#[get(method = "get", kind = "deref")] String);
-#[derive(Debug, Clone, Get)]
+#[allow(clippy::derived_hash_with_manual_eq)]
+#[derive(Debug, Clone, Hash, Get)]
struct VersionNumbers(#[get(method = "get", kind = "deref")] Vec<VersionNumber>);
-#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub enum VersionSuffixKind {
Alpha,
Beta,
@@ -49,19 +50,22 @@ pub enum VersionSuffixKind {
P,
}
-#[derive(Clone, Debug, Get)]
+#[allow(clippy::derived_hash_with_manual_eq)]
+#[derive(Clone, Debug, Hash, Get)]
pub struct VersionSuffix {
kind: VersionSuffixKind,
number: Option<VersionNumber>,
}
-#[derive(Debug, Clone, Get)]
+#[allow(clippy::derived_hash_with_manual_eq)]
+#[derive(Debug, Clone, Hash, Get)]
pub struct VersionSuffixes(#[get(method = "get", kind = "deref")] Vec<VersionSuffix>);
-#[derive(Debug, Clone, Get, PartialEq, Eq)]
+#[derive(Debug, Clone, Get, PartialEq, Eq, Hash)]
pub struct BuildId(#[get(method = "get", kind = "deref")] String);
-#[derive(Clone, Debug, Get)]
+#[allow(clippy::derived_hash_with_manual_eq)]
+#[derive(Clone, Debug, Hash, Get)]
pub struct Version {
numbers: VersionNumbers,
letter: Option<char>,
@@ -70,19 +74,19 @@ pub struct Version {
build_id: Option<BuildId>,
}
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub struct Wildcard;
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum SlotOperator {
Eq,
Star,
}
-#[derive(Clone, Debug, PartialEq, Eq, Get)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Get)]
pub struct SlotName(#[get(method = "name", kind = "deref")] String);
-#[derive(Clone, Debug, PartialEq, Eq)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub enum Slot {
Wildcard,
Equal,
@@ -96,28 +100,28 @@ pub enum Slot {
},
}
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum UseDepNegate {
Minus,
Exclamation,
}
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum UseDepSign {
Enabled,
Disabled,
}
-#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
pub enum UseDepCondition {
Eq,
Question,
}
-#[derive(Clone, Debug, PartialEq, Eq)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash)]
pub struct Repo(String);
-#[derive(Clone, Debug, PartialEq, Eq, Get)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Get)]
pub struct UseDep {
negate: Option<UseDepNegate>,
flag: UseFlag,
@@ -125,13 +129,13 @@ pub struct UseDep {
condition: Option<UseDepCondition>,
}
-#[derive(Clone, Debug, PartialEq, Eq, Get)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Get)]
pub struct Cp {
category: Category,
name: Name,
}
-#[derive(Clone, Debug, PartialEq, Eq, Get)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Get)]
pub struct Cpv {
category: Category,
name: Name,
@@ -139,7 +143,7 @@ pub struct Cpv {
slot: Option<Slot>,
}
-#[derive(Clone, Debug, Get, PartialEq, Eq)]
+#[derive(Clone, Debug, Get, PartialEq, Eq, Hash)]
pub struct Atom {
blocker: Option<Blocker>,
category: Category,
diff --git a/src/useflag/mod.rs b/src/useflag/mod.rs
index c5a6424..c367b1a 100644
--- a/src/useflag/mod.rs
+++ b/src/useflag/mod.rs
@@ -4,10 +4,10 @@ use get::Get;
mod parsers;
-#[derive(Clone, Debug, PartialEq, Eq, Get)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Get)]
pub struct UseFlag(#[get(method = "name", kind = "deref")] String);
-#[derive(Clone, Debug, PartialEq, Eq, Get)]
+#[derive(Clone, Debug, PartialEq, Eq, Hash, Get)]
pub struct IUseFlag {
default: bool,
flag: UseFlag,