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

Avoid accepting references to Copy types #330

Merged
merged 2 commits into from
Jun 15, 2022

Conversation

SabrinaJewson
Copy link
Contributor

Description

  • search accepts Option<IncludeExternal> instead of Option<&IncludeExternal>
  • featured_playlists accepts Option<chrono::DateTime<chrono::Utc>> instead of Option<&chrono::DateTime<chrono::Utc>>
  • current_user_top_artists[_manual] and current_user_top_tracks[_manual] accept Option<TimeRange> instead of Option<&TimeRange>

I didn’t do the same for Market parameters because they’re not Copy (although they could be) — I’ll leave it to a separate PR.

Motivation and Context

Accepting a reference to a Copy type is usually counterproductive, since you can just take it by value. For most types this makes the size of the parameters smaller, for the Option<chrono::DateTime<chrono::Utc>> it increases it from 8 bytes to 16 bytes but I think that’s acceptable.

Dependencies

None.

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

How has this been tested?

  • Test A: cargo test --features env-file

Copy link
Collaborator

@marioortizmanero marioortizmanero left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch! Thanks a bunch for so many contributions :^) That's something I wasn't very happy with either.

I didn’t do the same for Market parameters because they’re not Copy (although they could be) — I’ll leave it to a separate PR.

Sounds good to me.

@marioortizmanero
Copy link
Collaborator

Also, @ramsayleung, I'm merging the small PRs that are just nice to have and don't require discussion (like this one). But I'll leave the rest open to wait for your approval as well, in case you come up with a better solution or with any ideas.

@marioortizmanero marioortizmanero merged commit 2d9cba6 into ramsayleung:master Jun 15, 2022
@SabrinaJewson SabrinaJewson deleted the no-copy-ref branch June 15, 2022 15:40
@ramsayleung
Copy link
Owner

I'm merging the small PRs that are just nice to have and don't require discussion (like this one). But I'll leave the rest open to wait for your approval as well, in case you come up with a better solution or with any ideas.

Everything looks good to me too :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants