refactor(rules): apply idiomatic patterns and resolve clippy warnings

- Change add_rule parameter from Option<&String> to Option<&str> for better ergonomics
- Use iterator methods (flat_map, any) instead of manual loops and collections
- Collapse nested if conditions using let-else patterns
- Use format string interpolation instead of separate arguments
- Avoid unnecessary String allocations in label comparisons
- Update CLI code to use as_deref() for Option<String> to Option<&str> conversion
- Update all documentation examples and tests to match new API
- All functionality preserved; API is more idiomatic and efficient
This commit is contained in:
Jeremiah Russell
2025-10-19 08:29:35 +01:00
committed by Jeremiah Russell
parent a43eb9e4a2
commit 8f908df8f3
2 changed files with 28 additions and 33 deletions

View File

@@ -44,7 +44,7 @@ impl AddCli {
let message_age = MessageAge::new(self.period.to_string().as_str(), self.count)?;
let retention = Retention::new(message_age, generate);
config.add_rule(retention, self.label.as_ref(), self.delete);
config.add_rule(retention, self.label.as_deref(), self.delete);
config.save()
}
}