-
-
Notifications
You must be signed in to change notification settings - Fork 207
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
Possible implementations of rust convenience traits #297
Comments
As a general thought, i think we should try to implement most of these where it makes sense. As that helps the bindings be used throughout the rust ecosystem. For some specific thoughts: We could maybe implement Do we need our own We could implement It might be possible to implement |
The lack of |
Yep, there are quite a few hints toward providing The question is of course what we would do for deep-copies. It could be argued that someone cloning a |
I can definitely see how it's tricky to decide on the right API and semantics and thanks for linking the previous discussion. My spontaneous expectation, from my own use and understanding so far, would be that var a := MyType.new()
var b := a basically corresponds to let a: Gd<_> = MyType::new(); // made up example fn
let b = a.clone(); But I'm not here to revive the discussion and I'm sure I'm missing a ton of weird cases with my anecdotes, anyway. 😬 |
That's an interesting perspective. It would mean that copy-on-write types like It means the trait ( |
This is specifically for I think there's still room for more explicit methods or traits where it makes sense, so Would |
Not in the general case -- it works well for types that are "data bundles", i.e. classes that:
They typically have quite different usage than regular classes. One thing that can be useful for them is value semantics. But maybe there should be a dedicated For nodes, there's also the special case of |
Oh, I didn't realize it was possible to omit the |
Due to rust-lang/rust#41906 I'm always a bit scared of using a |
I'm also a proponent of "just because we can, doesn't mean we should" 🙂 Before implementing traits like |
As it is, this issue is too open-ended and has no clear actionable or condition after which it can be closed. It thus becomes a candidate for "perpetually open", which I'd like to avoid. Plus, I'm not a big fan of the approach, as stated before. These traits should be justified by use cases, like every other feature. Doing use-case-driven development ensures that all code in existence is actually useful (by definition) and has gone through consideration by maintainers. The alternative is that we end up adding a lot of code that might not benefit anyone at all, yet we keep paying the maintenance cost until eternity. Of course, simple things like There have already been several issues and PRs toward specific traits:
And some should likely be tracked around the time when a specific feature is going to be implemented (e.g. If you see traits in the above list that are missing and would add a lot of value right now, please speak up. We can then discuss and track those separately. I will close this issue by end of next week, so we keep the tracker focused on more concrete and higher-priority issues -- of which there are a lot 😀 |
Many standard rust types use various convenience traits to extend their functionality, we should consider which of these convenience traits we can and should implement.
An attempt at an exhaustive list of such traits:
Borrow
/BorrowMut
/ToOwned
Clone
Eq
/PartialEq
Ord
/PartialOrd
From
/TryFrom
(Into
shouldn't be directly implemented)AsRef
/AsMut
Default
Error
Debug
,Display
, andWrite
being most important.Future
IntoFuture
Hash
ToSocketAddrs
SliceIndex
FromStr
Wake
The text was updated successfully, but these errors were encountered: