-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Suggest using Cow on mixture of &'static str + Strings #320
Comments
Revisiting this, it is not clear to me if the ExprUseVisitor really can do the things we need. First, we need to look at the whole crate. We start from a set of every bound value, struct/tuple field or enum variant content that is of type So if we want to use the ExprUseVisitor, I think our delegate needs to have a |
I also need to implement |
I think this is medium to get at all, but hard to get right. @Manishearth am I on the right track? Or is there an easier path? |
I started a cow branch to get my code online. I think I have the Now I need to implement the |
@birkenfeld I seem to have problems getting the lifetimes right. Halp ❓ 😅 |
@llogiq how can I help? |
I posed a question on stackoverflow which luckily got the correct answer. The reason for the problem was that I had a wrong lifetime for the Delegate. |
This is a lot more complicated than I'd thought. I have to find local variables (similar to shadow), struct fields/enum variant args (I don't have anything similar yet), etc. to bind the "use" to the correct identity. I need a check if a |
I see a lot of owned strings in many places where a
Cow<'static, str>
will do. The latter will likely improve performance.How do we detect this? It's a value of type
String
which are only initialized with otherString
s from elsewhere or&'static str
(via.to_owned()
/.to_string()
). Also we should probably check if the value is part of the public interface (as we did recently withwrong_pub_self_convention
).I think this should be possible with the ExprUseVisitor – so I finally have a reason to check it out. 😄
The text was updated successfully, but these errors were encountered: