forked from gentoo-utils/gentoo-utils
allow slot to be only :* := :slot/sub= or :slot
This commit is contained in:
@@ -79,11 +79,17 @@ pub enum SlotOperator {
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Get)]
|
||||
pub struct SlotName(#[get(method = "name", kind = "deref")] String);
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, Get)]
|
||||
pub struct Slot {
|
||||
primary: Option<SlotName>,
|
||||
sub: Option<SlotName>,
|
||||
operator: Option<SlotOperator>,
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub enum Slot {
|
||||
Wildcard,
|
||||
Equal {
|
||||
primary: Option<SlotName>,
|
||||
sub: Option<SlotName>,
|
||||
},
|
||||
Name {
|
||||
primary: SlotName,
|
||||
sub: Option<SlotName>,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
@@ -575,19 +581,29 @@ impl fmt::Display for SlotName {
|
||||
|
||||
impl fmt::Display for Slot {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
if let Some(slot) = self.primary.as_ref() {
|
||||
write!(f, "{slot}")?;
|
||||
}
|
||||
match self {
|
||||
Self::Wildcard => write!(f, "*"),
|
||||
Self::Equal { primary, sub } => {
|
||||
if let Some(primary) = primary {
|
||||
write!(f, "{primary}")?;
|
||||
}
|
||||
|
||||
if let Some(sub) = self.sub.as_ref() {
|
||||
write!(f, "/{sub}")?;
|
||||
}
|
||||
if let Some(sub) = sub {
|
||||
write!(f, "/{sub}")?;
|
||||
}
|
||||
|
||||
if let Some(operator) = self.operator.as_ref() {
|
||||
write!(f, "{operator}")?;
|
||||
}
|
||||
write!(f, "=")
|
||||
}
|
||||
Self::Name { primary, sub } => {
|
||||
write!(f, "{primary}")?;
|
||||
|
||||
Ok(())
|
||||
if let Some(sub) = sub {
|
||||
write!(f, "/{sub}")?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user