-
Notifications
You must be signed in to change notification settings - Fork 196
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
Adding impl Display for enum #3391
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Some formatting and small suggestions
""" | ||
impl #{Display} for $UnknownVariantValue { | ||
fn fmt(&self, f: &mut #{Fmt}::Formatter) -> #{Fmt}::Result { | ||
write!(f,"{}",self.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
write!(f,"{}",self.0) | |
write!(f, "{}", self.0) |
""", | ||
) | ||
} | ||
rust(""" ${context.enumName}::Unknown(value) => write!(f,"{}",value) """) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust(""" ${context.enumName}::Unknown(value) => write!(f,"{}",value) """) | |
rust("""${context.enumName}::Unknown(value) => write!(f,"{}",value)""") |
CHANGELOG.next.toml
Outdated
@@ -28,3 +28,9 @@ message = "Add `try_into_http1x` and `try_from_http1x` to Request and Response c | |||
references = ["aws-sdk-rust#977", "smithy-rs#3365", "smithy-rs#3373"] | |||
meta = { "breaking" = false, "bug" = false, "tada" = false } | |||
author = "rcoh" | |||
|
|||
[[smithy-rs]] | |||
message = "Added impl Display trait to Enum." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message = "Added impl Display trait to Enum." | |
message = "Added impl `Display` to Enums." |
@@ -28,3 +28,9 @@ message = "Add `try_into_http1x` and `try_from_http1x` to Request and Response c | |||
references = ["aws-sdk-rust#977", "smithy-rs#3365", "smithy-rs#3373"] | |||
meta = { "breaking" = false, "bug" = false, "tada" = false } | |||
author = "rcoh" | |||
|
|||
[[smithy-rs]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this also impacts the SDK, we should add a duplicate entry under aws-sdk-rust
CHANGELOG.next.toml
Outdated
|
||
[[smithy-rs]] | ||
message = "Added impl Display trait to Enum." | ||
references = ["smithy-rs#3336"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
references = ["smithy-rs#3336"] | |
references = ["smithy-rs#3336", "smithy-rs#3391"] |
@@ -94,6 +94,8 @@ class ClientEnumGeneratorTest { | |||
""" | |||
assert_eq!(format!("{:?}", SomeEnum::Foo), "Foo"); | |||
assert_eq!(format!("{:?}", SomeEnum::Bar), "Bar"); | |||
assert_eq!(SomeEnum::Foo.to_string(), "Foo"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you have one of these go directly for format!("{}", value)
instead of to_string
for completeness?
119b2cf
to
85d40cc
Compare
""" | ||
impl #{Display} for $UnknownVariantValue { | ||
fn fmt(&self, f: &mut #{Fmt}::Formatter) -> #{Fmt}::Result { | ||
write!(f, "{}", self.0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed the formatting.
""", | ||
) | ||
} | ||
rust("""${context.enumName}::Unknown(value) => write!(f,"{}",value)""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed the formatting.
85d40cc
to
e95d5d1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Motivation and Context
This change address the #3335
Description
Added Display trait to the Enum.
Testing
Updated the ClientEnumGeneratorTest.kt which test the
impl Display
for the enums.Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.