-
Notifications
You must be signed in to change notification settings - Fork 108
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
Use Into<String> instead of ToString #2127
base: master
Are you sure you want to change the base?
Conversation
As discussed on #2118, ToString is overly generic because it includes any type that implements Display. Instead, we only want to accept string-like types (whether owned or not), which is better covered by Into<String>.
impl<const N: usize> From<&'_ HexString<N>> for String { | ||
fn from(hex: &HexString<N>) -> Self { | ||
hex.as_str().into() | ||
} | ||
} | ||
|
||
impl<const N: usize> From<HexString<N>> for String { | ||
fn from(hex: HexString<N>) -> Self { | ||
hex.as_str().into() | ||
} | ||
} |
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.
Why are these impls necessary? Where are they used?
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.
Internal tests pass hex strings to these APIs and fail without those impls.
How confident are you that our existing demos (I believe this is just I can answer all of these questions, but it is not my job as reviewer to do so, it is your job as PR author. The answers should be recorded in your PR description for posterity. |
I'm not, at all. I just offered a comment on the previous PR and you said you'd accept a followup PR changing those APIs. If there is no interest in changing them after all, feel free to close it. I'd argue it shouldn't be my job as a reviewer to issue followup PRs changing used traits either, since I'm working on other stuff, but here we are :) |
Description of Changes
As discussed on #2118, ToString is overly generic because it includes any type that implements Display.
Instead, we only want to accept string-like types (whether owned or not), which is better covered by Into.
API and ABI breaking changes
If this is an API or ABI breaking change, please apply the
corresponding GitHub label.
Expected complexity level and risk
2
How complicated do you think these changes are? Grade on a scale from 1 to 5,
where 1 is a trivial change, and 5 is a deep-reaching and complex change.
This complexity rating applies not only to the complexity apparent in the diff,
but also to its interactions with existing and future code.
If you answered more than a 2, explain what is complex about the PR,
and what other components it interacts with in potentially concerning ways.
Testing
Describe any testing you've done, and any testing you'd like your reviewers to do,
so that you're confident that all the changes work as expected!