summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Turner <jturner.usa@gmail.com>2025-11-22 01:03:14 +0000
committerJohn Turner <jturner.usa@gmail.com>2025-11-22 01:03:14 +0000
commite9603ce62ff9c53102c5e78375102aa031e433cb (patch)
tree3a0c2752ea43f3ffbffe8e27aeb1ccdbda2e46d6
parentbd0fec80f95327688a648e5b3cf049746bc48e8c (diff)
downloadgentoo-utils-e9603ce62ff9c53102c5e78375102aa031e433cb.tar.gz
represent 4th variant of slots, and disallow empty primary slot names
-rw-r--r--src/atom/mod.rs14
-rw-r--r--src/atom/parsers.rs11
2 files changed, 14 insertions, 11 deletions
diff --git a/src/atom/mod.rs b/src/atom/mod.rs
index 82cef15..0b31223 100644
--- a/src/atom/mod.rs
+++ b/src/atom/mod.rs
@@ -85,8 +85,9 @@ pub struct SlotName(#[get(method = "name", kind = "deref")] String);
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Slot {
Wildcard,
- Equal {
- primary: Option<SlotName>,
+ Equal,
+ NameEqual {
+ primary: SlotName,
sub: Option<SlotName>,
},
Name {
@@ -592,10 +593,11 @@ impl fmt::Display for Slot {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Wildcard => write!(f, "*"),
- Self::Equal { primary, sub } => {
- if let Some(primary) = primary {
- write!(f, "{primary}")?;
- }
+ Self::Equal => {
+ write!(f, "=")
+ }
+ Self::NameEqual { primary, sub } => {
+ write!(f, "{primary}")?;
if let Some(sub) = sub {
write!(f, "/{sub}")?;
diff --git a/src/atom/parsers.rs b/src/atom/parsers.rs
index 0272be1..fbbb2ce 100644
--- a/src/atom/parsers.rs
+++ b/src/atom/parsers.rs
@@ -210,16 +210,16 @@ impl<'a> Parseable<'a, &'a str> for Slot {
fn parser() -> Self::Parser {
let wildcard = tag("*").map(|_| Slot::Wildcard);
- let equals = SlotName::parser()
- .opt()
+ let equal = tag("=").map(|_| Slot::Equal);
+ let name_equal = SlotName::parser()
.and(SlotName::parser().preceded_by(tag("/")).opt())
.followed_by(tag("="))
- .map(|(primary, sub)| Slot::Equal { primary, sub });
+ .map(|(primary, sub)| Slot::NameEqual { primary, sub });
let name = SlotName::parser()
.and(SlotName::parser().preceded_by(tag("/")).opt())
- .map(|(primary, sub)| Slot::Name { primary, sub });
+ .map(|(primary, sub)| Self::Name { primary, sub });
- wildcard.or(equals).or(name)
+ wildcard.or(equal).or(name_equal).or(name)
}
}
@@ -585,6 +585,7 @@ mod test {
"<dev-haskell/wai-3.3:=[]",
">=kde-frameworks/kcrash-2.16.0:6*",
"0-f/merreka+m::k+",
+ "iev-a/h:/n=",
];
for atom in atoms {