Skip to content

Commit

Permalink
Merge pull request #484 from thirteenowls/fix-clippy
Browse files Browse the repository at this point in the history
Fix clippy warnings
  • Loading branch information
ramsayleung authored May 23, 2024
2 parents fade9d9 + 9452e82 commit 4a4f704
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions examples/auth_code_pkce.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(clippy::assigning_clones)]

use rspotify::{prelude::*, scopes, AuthCodePkceSpotify, Credentials, OAuth};

#[tokio::main]
Expand Down
2 changes: 2 additions & 0 deletions examples/with_auto_reauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion src/clients/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down
11 changes: 4 additions & 7 deletions src/clients/pagination/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,21 @@ use crate::{model::Page, ClientError, ClientResult};
/// Alias for `Iterator<Item = T>`, since sync mode is enabled.
pub type Paginator<'a, T> = Box<dyn Iterator<Item = T> + '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<T>>
where
Request: Fn(&Ctx, u32, u32) -> ClientResult<Page<T>>,
Request: 'a + Fn(&Ctx, u32, u32) -> ClientResult<Page<T>>,
{
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<T>>
pub fn paginate<'a, T: 'a, Request>(req: Request, page_size: u32) -> Paginator<'a, ClientResult<T>>
where
Request: Fn(u32, u32) -> ClientResult<Page<T>>,
Request: 'a + Fn(u32, u32) -> ClientResult<Page<T>>,
{
let pages = PageIterator {
req,
Expand Down

0 comments on commit 4a4f704

Please sign in to comment.