chore: refactor Handler struct initialization and add unnecessary_wraps lint allow

This commit is contained in:
Kiril Videlov 2023-11-16 16:10:55 +01:00 committed by Kiril Videlov
parent 14841d9848
commit 42652d9655

View File

@ -19,14 +19,15 @@ pub struct Handler {
impl Handler {
pub fn new() -> Self {
let quota: Quota = Quota::per_second(nonzero!(1_u32)); // 1 per second at most.
let quota = Quota::per_second(nonzero!(1_u32)); // 1 per second at most.
let limit: OnceCell<RateLimiter<NotKeyed, InMemoryState, QuantaClock>> = OnceCell::new();
Handler {
quota: quota,
quota,
limit: limit.into(),
}
}
#[allow(clippy::unnecessary_wraps)]
pub fn handle<P: AsRef<std::path::Path>>(
&self,
path: P,
@ -37,7 +38,7 @@ impl Handler {
let rate_limiter = self
.limit
.get_or_init(|| RateLimiter::direct(self.quota.clone()));
.get_or_init(|| RateLimiter::direct(self.quota));
if rate_limiter.check().is_ok() {
events.push(events::Event::VirtualBranch(*project_id));