represent 4th variant of slots, and disallow empty primary slot names

This commit is contained in:
John Turner
2025-11-22 01:03:14 +00:00
parent bd0fec80f9
commit e9603ce62f
2 changed files with 14 additions and 11 deletions

View File

@@ -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}")?;