Cargo clippy & format

This commit is contained in:
Natsu Kagami 2025-05-13 00:47:18 +02:00
parent cdd85dae71
commit c5f46dd7fe
Signed by: nki
GPG key ID: 55A032EB38B49ADB
22 changed files with 79 additions and 87 deletions

View file

@ -42,6 +42,12 @@ impl Drop for InteractionCollectorGuard {
}
}
impl Default for InteractionCollector {
fn default() -> Self {
Self::new()
}
}
impl InteractionCollector {
pub fn new() -> Self {
Self {
@ -51,7 +57,7 @@ impl InteractionCollector {
/// Create a new collector, returning a receiver.
pub fn create_collector(&self, msg: MessageId) -> InteractionCollectorGuard {
let (send, recv) = flume::unbounded();
self.channels.insert(msg.clone(), send);
self.channels.insert(msg, send);
InteractionCollectorGuard {
msg_id: msg,
ch: recv,

View file

@ -43,7 +43,7 @@ impl<T: CanEdit> CanEdit for WithHeaders<T> {
}
}
impl<'a> CanEdit for (Message, &'a Context) {
impl CanEdit for (Message, &Context) {
async fn get_message(&self) -> Result<Message> {
Ok(self.0.clone())
}
@ -56,7 +56,7 @@ impl<'a> CanEdit for (Message, &'a Context) {
}
}
impl<'a, 'b> CanEdit for (&'a ComponentInteraction, &'b Context) {
impl CanEdit for (&ComponentInteraction, &Context) {
async fn get_message(&self) -> Result<Message> {
Ok(self.0.get_response(&self.1.http).await?)
}
@ -72,7 +72,7 @@ impl<'a, 'b> CanEdit for (&'a ComponentInteraction, &'b Context) {
}
}
impl<'a, 'e, Env: Send + Sync> CanEdit for (ReplyHandle<'a>, CmdContext<'e, Env>) {
impl<Env: Send + Sync> CanEdit for (ReplyHandle<'_>, CmdContext<'_, Env>) {
async fn get_message(&self) -> Result<Message> {
Ok(self.0.message().await?.into_owned())
}
@ -326,13 +326,7 @@ pub async fn handle_pagination_reaction(
let new_page = match reaction {
PREV | FAST_PREV if page == 0 => return Ok(page),
PREV => page - 1,
FAST_PREV => {
if page < fast {
0
} else {
page - fast
}
}
FAST_PREV => page.saturating_sub(fast),
NEXT if pages.filter(|&pages| page as usize + 1 >= pages).is_some() => return Ok(page),
NEXT => page + 1,
FAST_NEXT => (pages.unwrap() as u8 - 1).min(page + fast),

View file

@ -50,14 +50,14 @@ impl<T> Ratelimit<T> {
}
}
impl<'a, T> Deref for RatelimitGuard<'a, T> {
impl<T> Deref for RatelimitGuard<'_, T> {
type Target = T;
fn deref(&self) -> &Self::Target {
self.inner
}
}
impl<'a, T> Drop for RatelimitGuard<'a, T> {
impl<T> Drop for RatelimitGuard<'_, T> {
fn drop(&mut self) {
let send = self.send.clone();
let wait_time = *self.wait_time;