-
Notifications
You must be signed in to change notification settings - Fork 666
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
Add Signal::as_str() to get representation as static string #1138
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.
This looks good. Could you also please include a CHANGELOG
entry, showing users how to switch from the old method to the new one?
Do docs look OK now? |
Yeah, looks good. Just wrap the comment to 80 columns and I'll merge. |
Done |
Note: I changed signature of as_str to take self by-value, because Signal is Copy |
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.
Perfect! Just squash your commits and I'll merge them. I can't squash your commits for you because Nix uses the bors merge bot.
Squashed. |
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.
bors r+
1138: Add Signal::as_str() to get representation as static string r=asomers a=MikailBag # Motivation Currently string representation of signal can be obtained with AsRef<str> impl. But it has downside: returned string's lifetime is bound to lifetime of signal, so &str must be converted to String. This allocation is avoidable, because as_ref() only returns static strings. To fix this problem, my PR adds Signal::as_str() method, which returns static string. Co-authored-by: Mikail Bagishov <bagishov.mikail@yandex.ru>
Build succeeded
|
Motivation
Currently string representation of signal can be obtained with AsRef impl.
But it has downside: returned string's lifetime is bound to lifetime of signal, so &str must be converted to String. This allocation is avoidable, because as_ref() only returns static strings. To fix this problem, my PR adds Signal::as_str() method, which returns static string.