From 9452e82ab89ce35a278a61b36c02d4e904d78e93 Mon Sep 17 00:00:00 2001 From: thirteenowls Date: Wed, 22 May 2024 16:32:33 +0200 Subject: [PATCH] Fix clippy warnings --- examples/auth_code_pkce.rs | 2 ++ examples/with_auto_reauth.rs | 2 ++ src/clients/base.rs | 2 +- src/clients/pagination/iter.rs | 11 ++++------- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/examples/auth_code_pkce.rs b/examples/auth_code_pkce.rs index fb3164ef..c256402b 100644 --- a/examples/auth_code_pkce.rs +++ b/examples/auth_code_pkce.rs @@ -1,3 +1,5 @@ +#![allow(clippy::assigning_clones)] + use rspotify::{prelude::*, scopes, AuthCodePkceSpotify, Credentials, OAuth}; #[tokio::main] diff --git a/examples/with_auto_reauth.rs b/examples/with_auto_reauth.rs index 6a5e3694..b3a16928 100644 --- a/examples/with_auto_reauth.rs +++ b/examples/with_auto_reauth.rs @@ -3,6 +3,8 @@ //! Spotify server, it will check whether the token is expired and automatically //! re-authenticate by refresh_token if set `Token.token_refreshing` to true. +#![allow(clippy::assigning_clones)] + use chrono::offset::Utc; use chrono::Duration; use rspotify::{ diff --git a/src/clients/base.rs b/src/clients/base.rs index ae1b81c0..59bf33d5 100644 --- a/src/clients/base.rs +++ b/src/clients/base.rs @@ -318,7 +318,7 @@ where let include_groups_opt = include_groups_vec .is_empty() .not() - .then_some(include_groups_vec) + .then(|| include_groups_vec) .map(|t| t.join(",")); let params = build_map([ diff --git a/src/clients/pagination/iter.rs b/src/clients/pagination/iter.rs index 07813b56..fc9bf27a 100644 --- a/src/clients/pagination/iter.rs +++ b/src/clients/pagination/iter.rs @@ -5,24 +5,21 @@ use crate::{model::Page, ClientError, ClientResult}; /// Alias for `Iterator`, since sync mode is enabled. pub type Paginator<'a, T> = Box + 'a>; -pub fn paginate_with_ctx<'a, Ctx: 'a, T: 'a, Request: 'a>( +pub fn paginate_with_ctx<'a, Ctx: 'a, T: 'a, Request>( ctx: Ctx, req: Request, page_size: u32, ) -> Paginator<'a, ClientResult> where - Request: Fn(&Ctx, u32, u32) -> ClientResult>, + Request: 'a + Fn(&Ctx, u32, u32) -> ClientResult>, { paginate(move |limit, offset| req(&ctx, limit, offset), page_size) } /// This is used to handle paginated requests automatically. -pub fn paginate<'a, T: 'a, Request: 'a>( - req: Request, - page_size: u32, -) -> Paginator<'a, ClientResult> +pub fn paginate<'a, T: 'a, Request>(req: Request, page_size: u32) -> Paginator<'a, ClientResult> where - Request: Fn(u32, u32) -> ClientResult>, + Request: 'a + Fn(u32, u32) -> ClientResult>, { let pages = PageIterator { req,