mirror of
https://github.com/ramsayleung/rspotify.git
synced 2026-04-26 07:55:55 +03:00
[PR #321] [MERGED] Remove unnecessary mutable references in clients #397
Labels
No labels
Stale
bug
discussion
enhancement
good first issue
good first issue
help wanted
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/rspotify#397
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ramsayleung/rspotify/pull/321
Author: @Spanfile
Created: 5/31/2022
Status: ✅ Merged
Merged: 6/2/2022
Merged by: @marioortizmanero
Base:
master← Head:master📝 Commits (2)
42ffc65Remove unnecessary mutable references in clients345993eRemove now unnecessary muts in examples📊 Changes
20 files changed (+25 additions, -25 deletions)
View changed files
📝
examples/auth_code.rs(+1 -1)📝
examples/client_creds.rs(+1 -1)📝
examples/oauth_tokens.rs(+1 -1)📝
examples/pagination_async.rs(+1 -1)📝
examples/pagination_manual.rs(+1 -1)📝
examples/pagination_sync.rs(+1 -1)📝
examples/tasks.rs(+1 -1)📝
examples/ureq/device.rs(+1 -1)📝
examples/ureq/me.rs(+1 -1)📝
examples/ureq/search.rs(+1 -1)📝
examples/ureq/seek_track.rs(+1 -1)📝
examples/ureq/threading.rs(+1 -1)📝
examples/webapp/src/main.rs(+3 -3)📝
examples/with_auto_reauth.rs(+2 -2)📝
examples/with_refresh_token.rs(+1 -1)📝
src/auth_code.rs(+1 -1)📝
src/auth_code_pkce.rs(+1 -1)📝
src/client_creds.rs(+1 -1)📝
src/clients/oauth.rs(+3 -3)📝
tests/test_with_credential.rs(+1 -1)📄 Description
Description
OAuthClient::request_tokentakes self as&mut, yet all of its implementors are designed for an async environment, where inner mutability for their fields is required throughArc<Mutex<_>>, as is the case for the token fields, thus self doesn't actually have to be a mutable reference. By making the reference immutable, it is much more comfortable to use the clients in application code, since there's no need to wrap them in e.g. a Mutex or an RwLock only for the one case where a mutable self is needlessly required.However,
AuthCodePkceSpotify::get_authorize_urlis still left as is to take self as&mutsince it has to set itsverifierfield, and converting that field toArc<Mutex<_>>and converting the function intoasyncwould be a breaking change, hence I've left it out of this PR.Motivation and Context
I've been using the library recently and ran into this ergonomics issue.
Dependencies
None.
Type of change
How has this been tested?
The crate test suite ran succesfully. I removed one unneeded
mutintests/test_with_credential.rs.Is this change properly documented?
I'm unsure if this is a breaking change, since existing application code will still work, it would just be beneficial for them to adapt to not requiring mutability anymore. If someone has implemented
OAuthClientfor their own type, though, it will be a breaking change since the trait signature has changed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.