Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix clippy warnings #484

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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