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

Implement Default when it is possible to #261

Merged
merged 4 commits into from
Oct 9, 2021
Merged

Implement Default when it is possible to #261

merged 4 commits into from
Oct 9, 2021

Conversation

marioortizmanero
Copy link
Collaborator

Description

This adds a #[derive(Default)] where it is possible. I've also included a couple minor fixes, like renaming a model with a typo, or updating the docs of intermediate structs (i.e. holders of Vec<T> which are then simplified to just a Vec<T> in the client).

Motivation and Context

This closes #33 and leaves #223 and #221 as the only issues left for the new release :))

Dependencies

None

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Tests still pass perfectly.

///
/// [Reference](https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-multiple-episodes)
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
#[derive(Deserialize)]
Copy link
Owner

Choose a reason for hiding this comment

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

Is it ok to remove Clone, Debug, Serialize, PartialEq, Eq, because we have changed the declaration of this struct.

Copy link
Collaborator Author

@marioortizmanero marioortizmanero Oct 8, 2021

Choose a reason for hiding this comment

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

Yes, this is just an intermediate model, so I've added the same derives as the rest of the intermediate models. We don't really expose it to the user, so Deserialize is enough.

@ramsayleung
Copy link
Owner

Everything looks good to me, except for one nitpick, that is it safe to implement Default trait for these models?

@marioortizmanero
Copy link
Collaborator Author

What do you mean by "safe"? It should do no harm, it's just additional functionality wherever it's possible.

@ramsayleung ramsayleung merged commit 3c319c1 into master Oct 9, 2021
@ramsayleung ramsayleung deleted the defaults branch October 9, 2021 00:21
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.

Create "default" values/Builder pattern for some structs
2 participants