mirror of
https://codeberg.org/YGGverse/psocks.git
synced 2026-03-31 16:35:28 +00:00
simplify logic
This commit is contained in:
parent
96b9646c8c
commit
a77bc468b6
1 changed files with 6 additions and 8 deletions
14
src/rules.rs
14
src/rules.rs
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue