Skip to content

Commit 358a1c7

Browse files
fix(rate-limiter): resolve clippy warnings for CI
- Add #[allow(clippy::should_implement_trait)] on Algorithm::from_str - Add Default impl for MemoryStore (new_without_default) - Replace map_or(false, ...) with is_some_and (unnecessary_map_or) Signed-off-by: Pratik Gandhi <gandhipratik203@gmail.com>
1 parent 7e14590 commit 358a1c7

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

plugins_rust/rate_limiter/src/config.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ pub enum Algorithm {
7878
}
7979

8080
impl Algorithm {
81+
/// Parse an algorithm name from a string.
82+
#[allow(clippy::should_implement_trait)]
8183
pub fn from_str(s: &str) -> Option<Self> {
8284
match s.trim().to_ascii_lowercase().as_str() {
8385
"fixed_window" => Some(Self::FixedWindow),

plugins_rust/rate_limiter/src/memory.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ pub struct MemoryStore {
6464
call_count: AtomicU64,
6565
}
6666

67+
impl Default for MemoryStore {
68+
fn default() -> Self {
69+
Self::new()
70+
}
71+
}
72+
6773
impl MemoryStore {
6874
pub fn new() -> Self {
6975
Self {
@@ -280,7 +286,7 @@ fn sliding_window(
280286
) -> DimResult {
281287
// Evict timestamps older than the window (amortized cleanup).
282288
let cutoff = now_mono.saturating_sub(window_nanos);
283-
while timestamps.front().map_or(false, |&t| t <= cutoff) {
289+
while timestamps.front().is_some_and(|&t| t <= cutoff) {
284290
timestamps.pop_front();
285291
}
286292

0 commit comments

Comments
 (0)