-
Notifications
You must be signed in to change notification settings - Fork 617
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
Implemented [&]Cow<str> for SharedString #6371
base: master
Are you sure you want to change the base?
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.
Thanks a lot for your PR.
I think it somehow makes sense.
Although this doesn't bring much value over shared_string.as_ref().into()
What is your use-case? Is the version that take a reference really necessary?
A small #[test]
would be nice.
internal/core/string.rs
Outdated
#[cfg(feature = "std")] | ||
use std::borrow::Cow; |
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.
You don't need feature="std" if you use it from alloc:
#[cfg(feature = "std")] | |
use std::borrow::Cow; | |
use alloc::borrow::Cow; |
then the feature="std" is also not needed later.
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.
Learned something new. Thanks!
(Note that in the std library, |
This change is clearly a very minor (borderline minuscule) improvement. Yes, it just saves an Strictly speaking, Thanks! |
`One thing i was considering was to make SharedString able to hold &'static str depending on some bit tag.
In this case, it would be nice if one could convert from In order to make it possible, would it make sense to restruct the implementation to Why do we need both |
In that case you would not be able to use the changes I made, as (to my knowledge) there would not be a way to have both an implementation that converts from Also, doesn't Slint rely
We probably don't - I suppose I was just "aping" what I saw with |
Title is self-explanatory