Add Signal::as_str() to get representation as static string#1138
Merged
bors[bot] merged 1 commit intonix-rust:masterfrom Oct 29, 2019
MikailBag:master
Merged
Add Signal::as_str() to get representation as static string#1138bors[bot] merged 1 commit intonix-rust:masterfrom MikailBag:master
bors[bot] merged 1 commit intonix-rust:masterfrom
MikailBag:master
Conversation
asomers
reviewed
Oct 19, 2019
Member
asomers
left a comment
There was a problem hiding this comment.
This looks good. Could you also please include a CHANGELOG entry, showing users how to switch from the old method to the new one?
Contributor
Author
|
Do docs look OK now? |
Member
|
Yeah, looks good. Just wrap the comment to 80 columns and I'll merge. |
Contributor
Author
|
Done |
Contributor
Author
|
Note: I changed signature of as_str to take self by-value, because Signal is Copy |
asomers
approved these changes
Oct 29, 2019
Member
asomers
left a comment
There was a problem hiding this comment.
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.
Contributor
Author
|
Squashed. |
bors bot
added a commit
that referenced
this pull request
Oct 29, 2019
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>
Contributor
Build succeeded
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.