-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Consider optionally owning the xcb connection #2
Comments
Hi @vikigenius. Thanks for the suggestion. I think this is definitely an idea worth exploring. I have to think a bit about the implications still. |
Or alternatively if generics is too complicated, we could just own the |
I was looking a bit into your first suggestion. These bounds would need either Regarding actually enforcing ownership of the Regarding your example I think the best way to go right now is to store the |
Thanks, for the suggestion I see your point and I managed to solve the problem I have the way you suggested. But this whole issue and discussion is fascinating to me after I have spent some time reading about the Rust view on inheritance. I would like to understand better some of your thought process since I am a relative beginner to Rust, please don't take it as a criticism of your approach. This brings me to a general problem with Rust that I have found. Composition and Delegation. The ultimate goal of this create is to:
The way I see it there are two major ways to achieve this.
You can't chose 1 because you have chosen to add additional state to the connection (the atoms). But why is that needed? You are not using it anywhere except for when interning all of them initially iiuc. Maybe we can just add a trait with a But now coming to the 2nd approach (wrapper) it is pretty diverse, this can be further broken down on how you plan to use the wrapper.
When it comes to 3, Rust has no easy way of delegation so you either have to manually copy paste all the implementations of your inner type. Or use Deref, which seems like an anti-pattern, since that is not it's original purpose. But at least in this specific case it kind of makes sense, since an EMH connection is an X connection. |
Sorry for the huge wall of text, but if you are interested I would like to get your thoughts on this, because I seem to run into similar problems a lot when designing wrapper types. |
@arminfriedl so xcb now does implement |
This is a follow up to my post in the Rust Forum
Perhaps it's a good idea to store either
Cow<'a, xcb::Connection>
instead of&'a xcb::Connection
in the ewmh connection Struct or even be generic overAsRef<xcb::Connection>
so that it can optionally own the connection ?I can contribute a PR if you think this is a good idea but don't have time to do this yourself.
The text was updated successfully, but these errors were encountered: