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

ClientType: Change from &'static str to String #205

Merged
merged 1 commit into from
Oct 31, 2022
Merged

ClientType: Change from &'static str to String #205

merged 1 commit into from
Oct 31, 2022

Conversation

kevinji
Copy link
Contributor

@kevinji kevinji commented Oct 28, 2022

Fixes #206.

Description

&'static str makes it impossible to deserialize ClientType and affects any structs including ClientType as well, so change it to use String instead.


PR author checklist:

  • Added changelog entry, using unclog.
  • Added tests.
  • Linked to GitHub issue.
  • Updated code comments and documentation (e.g., docs/).
  • Tagged one reviewer who will be the one responsible for shepherding this PR.

Reviewer checklist:

  • Reviewed Files changed in the GitHub PR explorer.
  • Manually tested (in case integration/unit/mock tests are absent).

@plafer
Copy link
Contributor

plafer commented Oct 28, 2022

Thank you for opening this PR. Could you:

  1. Open an issue which clearly describes the problem
  2. Mark this PR as closing this issue (i.e. add a line "Closes: #")
  3. Refer to this issue in the changelog

Specifically, I am not sure what you mean by "making it impossible to deserialize". For example, this works:

let deserialized: ClientType = serde_json::from_str("\"hello\"").unwrap();
println!("Deserialized: {:?}", deserialized);

Please expand on that in the issue. Thanks!

@kevinji
Copy link
Contributor Author

kevinji commented Oct 28, 2022

@plafer I added #206 to describe the issue further. I think your specific example works because "\"hello\"" happens to be a &'static str as it is a literal. If you instead had a function that took in a &str it would not work, as detailed in the issue.

&'static str makes it impossible to Deserialize and affects any structs
including ClientType as well, so change it to use String instead.
Copy link
Contributor

@plafer plafer left a comment

Choose a reason for hiding this comment

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

Thank you for the additional context! LGTM.

@plafer plafer merged commit 00f1e41 into cosmos:main Oct 31, 2022
@kevinji kevinji deleted the change-clienttype-string branch November 3, 2022 00:46
shuoer86 pushed a commit to shuoer86/ibc-rs that referenced this pull request Nov 4, 2023
* chore(rust): bump version to 0.11.0

* chore: Add compatibility table to the README
Farhad-Shabani pushed a commit that referenced this pull request Sep 9, 2024
&'static str makes it impossible to Deserialize and affects any structs
including ClientType as well, so change it to use String instead.
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.

Deserializing a ClientType requires an input with static lifetime
2 participants