impl Cpv type

This commit is contained in:
2025-11-13 18:03:34 +00:00
parent f4a45717d2
commit 1882ce3137
2 changed files with 65 additions and 1 deletions

View File

@@ -5,7 +5,7 @@ use mon::{Parser, ParserIter, r#if, numeric1, one_of, tag};
use crate::{
Parseable,
atom::{
Atom, Blocker, Category, Name, Slot, SlotName, SlotOperator, UseDep, UseDepCondition,
Atom, Blocker, Category, Cpv, Name, Slot, SlotName, SlotOperator, UseDep, UseDepCondition,
UseDepNegate, UseDepSign, Version, VersionNumber, VersionNumbers, VersionOperator,
VersionSuffix, VersionSuffixKind, VersionSuffixes,
},
@@ -334,6 +334,21 @@ impl<'a> Parseable<'a, &'a str> for Atom {
}
}
impl<'a> Parseable<'a, &'a str> for Cpv {
type Parser = impl Parser<&'a str, Output = Self>;
fn parser() -> Self::Parser {
Category::parser()
.and(Name::parser().preceded_by(tag("/")))
.and(Version::parser().preceded_by(tag("-")))
.map(|((category, name), version)| Cpv {
category,
name,
version,
})
}
}
#[cfg(test)]
mod test {