Skip to content

Commit

Permalink
Merge #282
Browse files Browse the repository at this point in the history
282: godot-core: delegate TypeStringHint on Option<T> to T r=Bromeon a=gg-yb

So when trying to export an array of resources property from my Rust struct I encountered the problem of crashes when the user adds null to the array (i.e. adding an element, not initializing it, then reopening the scene). I will open a separate issue for this.

However, in investigating this, I saw that TypeStringHint is not implemented for Option<Gd<T>>, only for Gd<T>. I feel that it should be implemented for that type as well, but I'm not sure delegating to Gd<T> is the right call here, that's why this is a draft.

Currently I just want to get this topic on the radar and spark discussion. However, should it turn out that delegating to Gd<T> here is the right thing to do, I believe the change can be applied as-is. From what I've seen from #241 there are no tests for TypeStringHint yet, so I haven't added any here, either.

Co-authored-by: gg-yb <[email protected]>
  • Loading branch information
bors[bot] and gg-yb authored Jun 17, 2023
2 parents 533a8d6 + 05c77f3 commit 57fd56a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions godot-core/src/obj/gd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,12 @@ impl<T: GodotClass> TypeStringHint for Gd<T> {
}
}

impl<T: TypeStringHint> TypeStringHint for Option<T> {
fn type_string() -> String {
<T>::type_string()
}
}

impl<T: GodotClass> Export for Gd<T> {
fn export(&self) -> Self {
self.share()
Expand Down

0 comments on commit 57fd56a

Please sign in to comment.