-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Use &[impl AsRef<str>]
instead of &[&str]
#89
Use &[impl AsRef<str>]
instead of &[&str]
#89
Conversation
Yes that would require some changes in gir (the utility used for generating the auto code). Do you want to have a look at updating that one as well? |
@bilelmoussaoui Yes, I just started browsing the gir codebase 🔍 |
I still see various |
S: AsRef<str>
, &[S]
instead of &[&str]
S: AsRef<str>
, &[S]
instead of &[&str]
Let's focus only on Also this needs some changes in https://github.com/gtk-rs/gir :) Thanks for looking into this, @rafaelcaricio! |
I've opened a PR in the gir repo to complement the changes: gtk-rs/gir#1149 |
Do you mind using that branch of gir and regenerate gtk-rs-core so we can see how those changes looks like? |
@bilelmoussaoui Would you like me to commit the generated changes here? |
yes please |
Cross-posting gtk-rs/gir#1149 (comment), perhaps |
@MarijnS95 Right, that would simplify things indeed. Just doesn't look natural!? Happy to make the change anyways.. just let me know what you all prefer. |
I personally prefer it since it's more concise, but this is not my project and I'm not a maintainer so :) |
4c39f6c
to
676ca66
Compare
I'd prefer |
I wonder if we could reduce trait bound complexity even further by using |
I'm all for it, please go ahead if you have some time :) |
Easy enough I'd say, gtk-rs/gir#1153. Still needs some more testing and scrutineering, but it's time for breakfast first :P |
If I understand the discussion here correctly, the PR gtk-rs/gir#1153 supersedes my PR gtk-rs/gir#1149 ? Now I should probably revert the commit I have in this PR to remove the generated code from my PR to gir? What would be the next steps? I'm a bit confused now. |
Hey! Apologies for the confusion! Your PR is not superseded at all :). Ideally we get gtk-rs/gir#1153 in first, as that only switches to I still have some finishing up to do, GStreamer-rs is pretty lenient but gtk-rs uses all the special types (async and futures with special trait bounds). After that I can help rebase your gir PR on top unless you wan to take care of that yourself. Let me know what approach you prefer! We can always get your gir PR merged first, and that I rebase my work on top (though that PR is already rather loaded and substantial, it's much easier to rebase smaller, trivial changes like yours on top instead of the other way around). |
@MarijnS95 I'm fine with waiting for your PR to get in first. This is my first contribution to those projects so I'm still figuring out my way around the code. |
On the case of using |
676ca66
to
80f23aa
Compare
S: AsRef<str>
, &[S]
instead of &[&str]
&[impl AsRef<str>]
instead of &[&str]
I've updated the PR with my latest changes, now we use |
It doesn't look like all occurences were replaced, some are still using an explicit type parameter. Was that intended? |
@MarijnS95 Could you point to one example where it was not replaced? |
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.
Quite a few places 😉
@MarijnS95 those are all manually added. That's why I wrote "I still need to update the manual code, but that is easy." :) Those occurrences are not generated by gir. |
769a4b9
to
1c82caf
Compare
Gotcha, I think I misread your original comment, but you definitely said that :) I cannot mark the comments as resolved though, not enough rights here :/ |
This is where I'm stuck. I cannot find a way to implement that trait bound without conflicting with existing trait bounds. 😢 |
obj.launch_uris_async( | ||
uris.as_ref(), | ||
uris, |
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.
Not sure this will actually compile, maybe after the trait bounds validation the compiler might complain about this ownership. But I can work out a solution for that later, that is fine..
It's a really tricky bugger indeed. I tried the obvious in implementing (with impl<'a, S: AsRef<str> + ToGlibPtr<'a, *const c_char>>
ToGlibContainerFromSlice<'a, *const *const c_char> for S (And later the various And that conflicts with the existing implementations. Neat I'd say, those should all be able to go through |
The alternative would be to go with |
We'd have to insert this for autogenerated code too, but I think the Alternatively |
@MarijnS95 Yes, I tried multiple ways... nothing worked, it always conflicted with something else. The suggestion from @sdroege was what I also think would be the best option. Any pointers to where to add that in gir are appreciated. 😄 |
This would rather use |
I've skip all code under
auto
folders as those are auto-generated. Maybe I could update the automatic code generation as well? 🤔