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

rust: remove Default implementation for enums #17294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions modules/openapi-generator/src/main/resources/rust/model.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ impl ToString for {{{classname}}} {
}
}
}

impl Default for {{{classname}}} {
fn default() -> {{{classname}}} {
{{#allowableValues}}
Self::{{ enumVars.0.name }}
{{/allowableValues}}
}
}
{{/isEnum}}

{{!-- for schemas that have a discriminator --}}
Expand Down Expand Up @@ -103,14 +95,6 @@ pub enum {{{enumName}}} {
{{/enumVars}}
{{/allowableValues}}
}

impl Default for {{{enumName}}} {
fn default() -> {{{enumName}}} {
{{#allowableValues}}
Self::{{ enumVars.0.name }}
{{/allowableValues}}
}
}
Copy link
Member

Choose a reason for hiding this comment

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

cc @Foorack who added these via #10720 to fix regression introduced by #10432 (authored by @PiDelport)

Copy link
Author

Choose a reason for hiding this comment

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

yup, #15856 reverted #10432. this change reverts #10720.

{{/isEnum}}
{{/vars}}

Expand Down
6 changes: 0 additions & 6 deletions samples/client/petstore/rust/hyper/petstore/src/models/baz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ impl ToString for Baz {
}
}

impl Default for Baz {
fn default() -> Baz {
Self::A
}
}




Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,3 @@ pub enum RequiredEnums {
C,
}

impl Default for RequiredEnums {
fn default() -> RequiredEnums {
Self::A
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ pub enum Status {
Delivered,
}

impl Default for Status {
fn default() -> Status {
Self::Placed
}
}

6 changes: 0 additions & 6 deletions samples/client/petstore/rust/hyper/petstore/src/models/pet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ pub enum Status {
Sold,
}

impl Default for Status {
fn default() -> Status {
Self::Available
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,3 @@ pub enum UniqueItemArray {
Variant3,
}

impl Default for UniqueItemArray {
fn default() -> UniqueItemArray {
Self::Variant1
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ impl ToString for Baz {
}
}

impl Default for Baz {
fn default() -> Baz {
Self::A
}
}




Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,3 @@ pub enum RequiredEnums {
C,
}

impl Default for RequiredEnums {
fn default() -> RequiredEnums {
Self::A
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ pub enum Status {
Delivered,
}

impl Default for Status {
fn default() -> Status {
Self::Placed
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ pub enum Status {
Sold,
}

impl Default for Status {
fn default() -> Status {
Self::Available
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,3 @@ pub enum UniqueItemArray {
Variant3,
}

impl Default for UniqueItemArray {
fn default() -> UniqueItemArray {
Self::Variant1
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ impl ToString for Baz {
}
}

impl Default for Baz {
fn default() -> Baz {
Self::A
}
}




Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,3 @@ pub enum RequiredEnums {
C,
}

impl Default for RequiredEnums {
fn default() -> RequiredEnums {
Self::A
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ pub enum Status {
Delivered,
}

impl Default for Status {
fn default() -> Status {
Self::Placed
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ pub enum Status {
Sold,
}

impl Default for Status {
fn default() -> Status {
Self::Available
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,3 @@ pub enum UniqueItemArray {
Variant3,
}

impl Default for UniqueItemArray {
fn default() -> UniqueItemArray {
Self::Variant1
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ impl ToString for Baz {
}
}

impl Default for Baz {
fn default() -> Baz {
Self::A
}
}




Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,3 @@ pub enum RequiredEnums {
C,
}

impl Default for RequiredEnums {
fn default() -> RequiredEnums {
Self::A
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ pub enum Status {
Delivered,
}

impl Default for Status {
fn default() -> Status {
Self::Placed
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ pub enum Status {
Sold,
}

impl Default for Status {
fn default() -> Status {
Self::Available
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,3 @@ pub enum UniqueItemArray {
Variant3,
}

impl Default for UniqueItemArray {
fn default() -> UniqueItemArray {
Self::Variant1
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@ impl ToString for Baz {
}
}

impl Default for Baz {
fn default() -> Baz {
Self::A
}
}




Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,3 @@ pub enum RequiredEnums {
C,
}

impl Default for RequiredEnums {
fn default() -> RequiredEnums {
Self::A
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ pub enum Status {
Delivered,
}

impl Default for Status {
fn default() -> Status {
Self::Placed
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,3 @@ pub enum Status {
Sold,
}

impl Default for Status {
fn default() -> Status {
Self::Available
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,3 @@ pub enum UniqueItemArray {
Variant3,
}

impl Default for UniqueItemArray {
fn default() -> UniqueItemArray {
Self::Variant1
}
}

Loading