From 0b63f8943f63968060c3ce034f20f0e371efa8ed Mon Sep 17 00:00:00 2001 From: Mario Ortiz Manero Date: Sun, 3 Jul 2022 19:18:38 +0200 Subject: [PATCH] Use more string formatting capture --- examples/webapp/src/main.rs | 2 +- rspotify-model/src/idtypes.rs | 4 ++-- src/clients/base.rs | 8 ++++---- src/clients/oauth.rs | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/webapp/src/main.rs b/examples/webapp/src/main.rs index 78d13d0b..b94d3e40 100644 --- a/examples/webapp/src/main.rs +++ b/examples/webapp/src/main.rs @@ -149,7 +149,7 @@ fn index(mut cookies: Cookies) -> AppResponse { AppResponse::Template(Template::render("index", context.clone())) } Err(err) => { - context.insert("err_msg", format!("Failed for {}!", err)); + context.insert("err_msg", format!("Failed for {err}!")); AppResponse::Template(Template::render("error", context)) } } diff --git a/rspotify-model/src/idtypes.rs b/rspotify-model/src/idtypes.rs index fae2c9c5..29b21640 100644 --- a/rspotify-model/src/idtypes.rs +++ b/rspotify-model/src/idtypes.rs @@ -579,7 +579,7 @@ mod test { // Easily testing both ways to obtain an ID test_any(|s| TrackId::from_id_or_uri(s)); test_any(|s| { - let json = format!("\"{}\"", s); + let json = format!("\"{s}\""); serde_json::from_str::<'_, TrackId>(&json) }); } @@ -587,7 +587,7 @@ mod test { /// Serializing should return the Id within it, not the URI. #[test] fn test_serialize() { - let json_expected = format!("\"{}\"", ID); + let json_expected = format!("\"{ID}\""); let track = TrackId::from_uri(URI).unwrap(); let json = serde_json::to_string(&track).unwrap(); assert_eq!(json, json_expected); diff --git a/src/clients/base.rs b/src/clients/base.rs index 301b66f0..392b10b5 100644 --- a/src/clients/base.rs +++ b/src/clients/base.rs @@ -265,7 +265,7 @@ where let ids = join_ids(track_ids); let params = build_map([("market", market.map(|x| x.into()))]); - let url = format!("tracks/?ids={}", ids); + let url = format!("tracks/?ids={ids}"); let result = self.endpoint_get(&url, ¶ms).await?; convert_result::(&result).map(|x| x.tracks) } @@ -293,7 +293,7 @@ where artist_ids: impl IntoIterator> + Send + 'a, ) -> ClientResult> { let ids = join_ids(artist_ids); - let url = format!("artists/?ids={}", ids); + let url = format!("artists/?ids={ids}"); let result = self.endpoint_get(&url, &Query::new()).await?; convert_result::(&result).map(|x| x.artists) @@ -410,7 +410,7 @@ where album_ids: impl IntoIterator> + Send + 'a, ) -> ClientResult> { let ids = join_ids(album_ids); - let url = format!("albums/?ids={}", ids); + let url = format!("albums/?ids={ids}"); let result = self.endpoint_get(&url, &Query::new()).await?; convert_result::(&result).map(|x| x.albums) } @@ -837,7 +837,7 @@ where ("offset", offset.as_deref()), ]); - let url = format!("browse/categories/{}/playlists", category_id); + let url = format!("browse/categories/{category_id}/playlists"); let result = self.endpoint_get(&url, ¶ms).await?; convert_result::(&result).map(|x| x.playlists) } diff --git a/src/clients/oauth.rs b/src/clients/oauth.rs index 60823f4d..44d6e4a0 100644 --- a/src/clients/oauth.rs +++ b/src/clients/oauth.rs @@ -1145,7 +1145,7 @@ pub trait OAuthClient: BaseClient { /// [Reference](https://developer.spotify.com/documentation/web-api/reference/#/operations/seek-to-position-in-currently-playing-track) async fn seek_track(&self, position_ms: u32, device_id: Option<&str>) -> ClientResult<()> { let url = append_device_id( - &format!("me/player/seek?position_ms={}", position_ms), + &format!("me/player/seek?position_ms={position_ms}"), device_id, ); self.endpoint_put(&url, &json!({})).await?; @@ -1183,7 +1183,7 @@ pub trait OAuthClient: BaseClient { "volume must be between 0 and 100, inclusive" ); let url = append_device_id( - &format!("me/player/volume?volume_percent={}", volume_percent), + &format!("me/player/volume?volume_percent={volume_percent}"), device_id, ); self.endpoint_put(&url, &json!({})).await?; @@ -1199,7 +1199,7 @@ pub trait OAuthClient: BaseClient { /// /// [Reference](https://developer.spotify.com/documentation/web-api/reference/#/operations/toggle-shuffle-for-users-playback) async fn shuffle(&self, state: bool, device_id: Option<&str>) -> ClientResult<()> { - let url = append_device_id(&format!("me/player/shuffle?state={}", state), device_id); + let url = append_device_id(&format!("me/player/shuffle?state={state}"), device_id); self.endpoint_put(&url, &json!({})).await?; Ok(())