-
-
Notifications
You must be signed in to change notification settings - Fork 260
Bugfix: Ease AsArg<Option<Gd<T>>> bounds to make it usable with signals.
#1371
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
Conversation
|
API docs are being generated and will be shortly available at: https://godot-rust.github.io/docs/gdext/pr-1371 |
Bromeon
left a comment
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.
Thanks! The logic error here was likely that base would be strictly a base class, but the Inherits bound is also implemented for the class itself.
godot-core/src/meta/args/as_arg.rs
Outdated
| /// // With move: | ||
| /// self.signals().signal_optional_user_obj().emit(Some(arg).as_ref()); |
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.
This only tests as_ref() doing &Option<T> -> Option<&T>, which isn't godot-rust specific.
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.
true, testing it is silly.
godot-core/src/meta/args/as_arg.rs
Outdated
| /// // With None (Note: Gd::null_arg() is restricted): | ||
| /// self.signals().signal_optional_user_obj().emit(None::<Gd<MyClass>>.as_ref()); |
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.
Also here?
What do you mean with "restricted", could you clarify?
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.
Limited to engine classes
b094d40 to
57f4206
Compare
Long story short
AsArg<Option<Gd<T>>bounds were too restrictive which made it unusable with user-defined classes (despiteOption<Gd<MyClass>>being totally valid).In other words, this did not compile:
compile error
Since it is compilation error only I covered it with doctests (I'm pretty sure doctest works because it failed on me three times due to typos and whatnot).
Gd:null_argremains unchanged (idk what to think about it -let arg: Option<Gd<MyClass> = None;ain't that bad).Reported by Iride Lombardi on discord (thanks!): https://discord.com/channels/723850269347283004/1429013604258025554/1429013604258025554