Use Display instead of ToString in Rust generators - #18633
Merged
Conversation
Member
|
thanks for the PR. if no one else has further feedback on this change, I'll merge it over the weekend. have a nice weekend. |
dani-garcia
added a commit
to bitwarden/sdk-sm
that referenced
this pull request
May 13, 2024
## Type of change ``` - [ ] Bug fix - [ ] New feature development - [x] Tech debt (refactoring, code cleanup, dependency upgrades, etc) - [ ] Build/deploy pipeline (DevOps) - [ ] Other ``` ## Objective Latest Rust 1.78 includes a [clippy warning](https://rust-lang.github.io/rust-clippy/master/index.html#/to_string_trait_impl) when implementing ToString directly instead of using Display, which would also derive `ToString` for free. Note that there are a few uses of `impl ToString` in the `bitwarden-api-*` packages but I haven't changed those here. I've opened a PR in openapi-generator OpenAPITools/openapi-generator#18633
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With the latest 1.78 release of Rust, Clippy has introduced a lint warning against the direct implementation of
ToString, recommending instead to implementDisplay: https://rust-lang.github.io/rust-clippy/master/index.html#/to_string_trait_implThis PR changes the uses of
impl ToStringin the Rust generator template forimpl Display. It also updates the Rust samples. Note that becauseDisplayhas a blanket implementation ofToString, the resulting enums will still implementToString, so this doesn't break anything.Tagging
openapi-generatorRust committee, like the checklist mentions: @frol @farcaller @richardwhiuk @paladinzh @jacob-proPR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming 7.1.0 minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)