This commit is contained in:
tezlm 2023-10-10 00:18:32 -07:00
parent 7ec1ec2473
commit 928bd3c08f
Signed by: tezlm
GPG key ID: 649733FCD94AFBBA

View file

@ -26,7 +26,7 @@ pub struct P2Entry {
#[derive(Debug, PartialEq, Eq, Clone)]
pub struct P2Rule {
ops: Vec<P2RuleOp>,
depends: Vec<String>,
depends: Vec<Box<str>>,
}
#[derive(Debug, PartialEq, Eq, Clone)]
@ -107,14 +107,14 @@ pub enum P2Action {
Mark,
/// a custom action that won't be handled by the server
Custom(String),
Custom(Box<str>),
}
#[derive(Debug, Default, Serialize, Deserialize)]
pub struct P2Counters {
pub counters: HashMap<Box<str>, u64>,
#[serde(flatten)]
_other: HashMap<String, JVal>,
_other: HashMap<Box<str>, JVal>,
}
macro_rules! rgx {
@ -139,7 +139,7 @@ fn topological_sort(vec: &mut Vec<(Box<str>, P2Entry)>) -> bool {
.rule
.depends
.iter()
.all(|dep| vec.iter().any(|(name, _)| name.as_ref() == dep.as_str()));
.all(|dep| vec.iter().any(|(name, _)| name == dep));
if has_deps {
to_remove.push(idx);
}
@ -251,7 +251,7 @@ impl P2Rule {
fn generate(
tokens: &mut Peekable<IntoIter<(P2TokenType, Option<&str>)>>,
ops: &mut Vec<P2RuleOp>,
depends: &mut Vec<String>,
depends: &mut Vec<Box<str>>,
) -> Result<(), P2RuleError> {
match tokens.next() {
Some((P2TokenType::Ident, Some(ident))) => {
@ -326,7 +326,7 @@ impl P2Rule {
Some((_, _)) => return Err(P2RuleError::InvalidToken),
None => return Err(P2RuleError::UnexpectedEOF),
};
depends.push(rule.to_string());
depends.push(rule.to_string().into_boxed_str());
ops.push(P2RuleOp::Rule(rule.to_string().into_boxed_str()));
}
Some((_, _)) => return Err(P2RuleError::InvalidToken),
@ -697,7 +697,7 @@ impl<'de> Deserialize<'de> for P2Action {
#[serde(untagged)]
pub enum FakeP2ActionWrapper {
Known(FakeP2Action),
Unknown(String),
Unknown(Box<str>),
}
let fake = FakeP2ActionWrapper::deserialize(deserializer)?;