Skip to content

Commit

Permalink
Use more string formatting capture
Browse files Browse the repository at this point in the history
  • Loading branch information
marioortizmanero committed Jul 3, 2022
1 parent a0b47e6 commit 0b63f89
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion examples/webapp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}
Expand Down
4 changes: 2 additions & 2 deletions rspotify-model/src/idtypes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -579,15 +579,15 @@ 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)
});
}

/// 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);
Expand Down
8 changes: 4 additions & 4 deletions src/clients/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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, &params).await?;
convert_result::<FullTracks>(&result).map(|x| x.tracks)
}
Expand Down Expand Up @@ -293,7 +293,7 @@ where
artist_ids: impl IntoIterator<Item = ArtistId<'a>> + Send + 'a,
) -> ClientResult<Vec<FullArtist>> {
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::<FullArtists>(&result).map(|x| x.artists)
Expand Down Expand Up @@ -410,7 +410,7 @@ where
album_ids: impl IntoIterator<Item = AlbumId<'a>> + Send + 'a,
) -> ClientResult<Vec<FullAlbum>> {
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::<FullAlbums>(&result).map(|x| x.albums)
}
Expand Down Expand Up @@ -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, &params).await?;
convert_result::<CategoryPlaylists>(&result).map(|x| x.playlists)
}
Expand Down
6 changes: 3 additions & 3 deletions src/clients/oauth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;
Expand Down Expand Up @@ -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?;
Expand All @@ -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(())
Expand Down

0 comments on commit 0b63f89

Please sign in to comment.