-
Notifications
You must be signed in to change notification settings - Fork 136
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
Extend string types #293
Extend string types #293
Conversation
… and `FromIterator<&'a char>` for String and WString ros2-rust#246
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.
Thanks for your PR! I left a comment.
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.
LGTM, just some small changes to tidy up are remaining.
rosidl_runtime_rs/src/string.rs
Outdated
@@ -224,6 +225,42 @@ macro_rules! string_impl { | |||
} | |||
} | |||
|
|||
impl From<&std::string::String> for $string { |
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.
Since the existing From<&str>
impl is more general, I think this impl isn't necessary.
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.
So in *self = Self::from(&s);
, &s
is actually of type &String
and From
isn't implemented for that type. So I removed this impl by just using Self::from(s.as_str())
in the Extend
impl
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.
That's correct, though using Self::from(&s)
should work too due to Deref coercion.
@@ -126,21 +126,6 @@ macro_rules! string_impl { | |||
) -> bool; | |||
} | |||
|
|||
impl Default for $string { |
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.
Alphabetizing the trait impl's
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.
Thanks for making these changes!
Thanks for all the guidance :) |
Implemented
Extend<char>
,Extend<&'a char>
,FromIterator<char>
, andFromIterator<&'a char>
for String and WString.Of note here is that with this change, String and WString now have interior mutability so they are no longer able to implement
Sync
safely.Original Issue: #246