simplify logic

This commit is contained in:
yggverse 2026-03-28 06:42:24 +02:00
parent 96b9646c8c
commit a77bc468b6

View file

@ -26,26 +26,24 @@ impl Rules {
/// Reload rule set by alias from it source
/// * `None` to reload all
pub async fn reload(&mut self, list_alias: Option<&str>) -> Result<Vec<String>> {
let mut affected = Vec::with_capacity(if list_alias.is_some() {
1
} else {
self.0.len()
});
match list_alias {
Ok(match list_alias {
Some(alias) => {
let mut affected = Vec::with_capacity(1);
if let Some(list) = self.0.get_mut(alias) {
list.reload().await?;
affected.push(alias.into());
}
affected
}
None => {
let mut affected = Vec::with_capacity(self.0.len());
for (alias, list) in self.0.iter_mut() {
list.reload().await?;
affected.push(alias.into());
}
affected
}
}
Ok(affected)
})
}
/// Check if rule is exist in the index
pub fn any(&self, value: &str) -> bool {