Skip to content

Commit 0f88c30

Browse files
committed
resolve clippy lints
1 parent 396062c commit 0f88c30

File tree

1 file changed

+11
-9
lines changed
  • twilight-http-ratelimiting/src

1 file changed

+11
-9
lines changed

twilight-http-ratelimiting/src/lib.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,7 @@ impl Permit {
209209
/// on receiving a response.
210210
#[allow(clippy::missing_panics_doc)]
211211
pub fn complete(self, headers: Option<RateLimitHeaders>) {
212-
if self.0.send(headers).is_err() {
213-
panic!("{ACTOR_PANIC_MESSAGE}");
214-
}
212+
assert!(self.0.send(headers).is_ok(), "{ACTOR_PANIC_MESSAGE}");
215213
}
216214
}
217215

@@ -224,6 +222,7 @@ impl Future for PermitFuture {
224222
type Output = Permit;
225223

226224
fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
225+
#[allow(clippy::match_wild_err_arm)]
227226
Pin::new(&mut self.0).poll(cx).map(|r| match r {
228227
Ok(sender) => Permit(sender),
229228
Err(_) => panic!("{ACTOR_PANIC_MESSAGE}"),
@@ -289,9 +288,10 @@ impl RateLimiter {
289288
pub fn acquire(&self, endpoint: Endpoint) -> PermitFuture {
290289
let (notifier, rx) = oneshot::channel();
291290
let message = actor::Message { endpoint, notifier };
292-
if self.tx.send((message, None)).is_err() {
293-
panic!("{ACTOR_PANIC_MESSAGE}");
294-
}
291+
assert!(
292+
self.tx.send((message, None)).is_ok(),
293+
"{ACTOR_PANIC_MESSAGE}"
294+
);
295295

296296
PermitFuture(rx)
297297
}
@@ -334,9 +334,10 @@ impl RateLimiter {
334334
{
335335
let (notifier, rx) = oneshot::channel();
336336
let message = actor::Message { endpoint, notifier };
337-
if self.tx.send((message, Some(Box::new(predicate)))).is_err() {
338-
panic!("{ACTOR_PANIC_MESSAGE}");
339-
}
337+
assert!(
338+
self.tx.send((message, Some(Box::new(predicate)))).is_ok(),
339+
"{ACTOR_PANIC_MESSAGE}"
340+
);
340341

341342
MaybePermitFuture(rx)
342343
}
@@ -354,6 +355,7 @@ impl RateLimiter {
354355
})
355356
.await;
356357

358+
#[allow(clippy::match_wild_err_arm)]
357359
match rx.await {
358360
Ok(bucket) => bucket,
359361
Err(_) => panic!("{ACTOR_PANIC_MESSAGE}"),

0 commit comments

Comments
 (0)