forked from gentoo-utils/gentoo-utils
impl Cp type
This commit is contained in:
@@ -108,6 +108,12 @@ pub struct UseDep {
|
|||||||
condition: Option<UseDepCondition>,
|
condition: Option<UseDepCondition>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Eq, Get)]
|
||||||
|
pub struct Cp {
|
||||||
|
category: Category,
|
||||||
|
name: Name,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Eq, Get)]
|
#[derive(Clone, Debug, PartialEq, Eq, Get)]
|
||||||
pub struct Cpv {
|
pub struct Cpv {
|
||||||
category: Category,
|
category: Category,
|
||||||
@@ -558,6 +564,12 @@ impl fmt::Display for UseDep {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Cp {
|
||||||
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
|
write!(f, "{}/{}", &self.category, &self.name)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl fmt::Display for Cpv {
|
impl fmt::Display for Cpv {
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||||
write!(f, "{}/{}-{}", &self.category, &self.name, &self.version)
|
write!(f, "{}/{}-{}", &self.category, &self.name, &self.version)
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ use mon::{Parser, ParserIter, r#if, numeric1, one_of, tag};
|
|||||||
use crate::{
|
use crate::{
|
||||||
Parseable,
|
Parseable,
|
||||||
atom::{
|
atom::{
|
||||||
Atom, Blocker, Category, Cpv, Name, Slot, SlotName, SlotOperator, UseDep, UseDepCondition,
|
Atom, Blocker, Category, Cp, Cpv, Name, Slot, SlotName, SlotOperator, UseDep,
|
||||||
UseDepNegate, UseDepSign, Version, VersionNumber, VersionNumbers, VersionOperator,
|
UseDepCondition, UseDepNegate, UseDepSign, Version, VersionNumber, VersionNumbers,
|
||||||
VersionSuffix, VersionSuffixKind, VersionSuffixes,
|
VersionOperator, VersionSuffix, VersionSuffixKind, VersionSuffixes,
|
||||||
},
|
},
|
||||||
useflag::UseFlag,
|
useflag::UseFlag,
|
||||||
};
|
};
|
||||||
@@ -334,6 +334,16 @@ impl<'a> Parseable<'a, &'a str> for Atom {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> Parseable<'a, &'a str> for Cp {
|
||||||
|
type Parser = impl Parser<&'a str, Output = Self>;
|
||||||
|
|
||||||
|
fn parser() -> Self::Parser {
|
||||||
|
Category::parser()
|
||||||
|
.and(Name::parser().preceded_by(tag("/")))
|
||||||
|
.map(|(category, name)| Cp { category, name })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> Parseable<'a, &'a str> for Cpv {
|
impl<'a> Parseable<'a, &'a str> for Cpv {
|
||||||
type Parser = impl Parser<&'a str, Output = Self>;
|
type Parser = impl Parser<&'a str, Output = Self>;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user