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

Replace bool with enum for a function parameter of label::fmt_string #1875

Merged
merged 8 commits into from
Oct 25, 2022

Conversation

ysaito1001
Copy link
Contributor

@ysaito1001 ysaito1001 commented Oct 18, 2022

Motivation and Context

Fixes #964

Description

This commit is a refactoring where the said function takes a bool to decide whether it percent-encodes the UTF-8 encoding of / in the given string. For clarity, we define an enum EncodingStrategy so that we can better express the callers' intent at the call sites with the variant names rather than true/false.

In addition, the PR includes two tangential changes:

  • label::fmt_timestamp calls label::fmt_string (one in its own module) rather than query::fmt_string. I made this change with the intent that if some operation can be completed without reaching into another module, it's more self-contained. I'm open to opinions/suggestions/preferences as to whether we revert the change.
  • BASE_SET is now pub(crate) so that we don't need to export it from the crate.

Testing

Ran cargo t from aws/rust-runtime

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

This commit addresses code smell where the said function takes a bool
to decide whether it percent-encodes the UTF-8 encoding of the given
string. For clarity, we define an enum EncodingStrategy so that we
can see the callers' intent at the call sites by reading the variant
names rather than true/false.
@ysaito1001 ysaito1001 requested a review from a team as a code owner October 18, 2022 21:21
@ysaito1001 ysaito1001 requested a review from a team as a code owner October 18, 2022 21:26
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link
Collaborator

@jdisanti jdisanti left a comment

Choose a reason for hiding this comment

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

LGTM!

CHANGELOG.next.toml Outdated Show resolved Hide resolved
Co-authored-by: John DiSanti <[email protected]>
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Saito added 2 commits October 19, 2022 14:15
This commit modifies a call site for the updated function signature of
`aws_smithy_http::label::fmt_string`, otherwise the test would fail to
compile, leading to a failure in CI.
@ysaito1001 ysaito1001 requested a review from a team October 19, 2022 19:26
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@ysaito1001 ysaito1001 enabled auto-merge (squash) October 25, 2022 15:53
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@ysaito1001 ysaito1001 merged commit b4f294c into main Oct 25, 2022
@ysaito1001 ysaito1001 deleted the ysaito/replace-bool-parameter-with-enum branch October 25, 2022 20:39
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.

Don't use booleans as function argument for function with 2+ arguments
4 participants