-
-
Notifications
You must be signed in to change notification settings - Fork 218
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
AsObjectArg
trait enabling implicit conversions for object parameters
#800
Conversation
Can't comment much as I don't really understand what this will achieve. With this I see you are not calling explicitly .clone anymore in some cases. Does it still clone in those cases or not anymore? |
Possibly in the initial implementation, but my plan is definitely to get rid of any unnecessary clones. Since this would then be an internal perf improvement, it might be a separate PR. |
I think we could just use This would probably force the trait to be an unsafe trait though, since it'd effectively erase the type. But it should also simplify implementation a fair bit. |
The problem with I might see how bad it is, maybe we can reuse code somehow. |
fa413fa
to
475fc0d
Compare
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-800 |
AsArg
trait enabling implicit conversions for object parameters (WIP)AsObjectArg
trait enabling implicit conversions for object parameters
56f6387
to
f1b25a5
Compare
f1b25a5
to
733a776
Compare
733a776
to
84505ba
Compare
Also declared bugfix, since it fixes #156 which wasn't previously possible. |
Adds a trait
AsObjectArg<T>
.Godot engine functions that have a parameter
impl AsObjectArg<T>
will now accept:Gd<U>
whereU: Inherits<T>
&Gd<U>
Option<Gd<U>>
Option<&Gd<U>>
Gd::null_arg()
, a special expression only valid for null argumentsCloses #156.
Closes #796.
Needs to land in v0.2 because some call-site patterns like
node.clone().upcast()
are now ambiguous and no longer possible.Older message
To be decided:
impl AsArg<T> for Gd<T>
(i.e. values, not just references)?&obj
Option<Gd<T>>
andOption<&Gd<T>>
are supported)RawGd
creates lots of copies, and may be unsafe/unsound to cast, plus needs destructor deactivatedArgView
type wrapping a pointer?