Skip to content

Commit 30cd060

Browse files
committed
Hot reload: reproduce #[class(no_init)] problem in test
1 parent 7c7498e commit 30cd060

File tree

1 file changed

+17
-0
lines changed
  • itest/hot-reload/rust/src

1 file changed

+17
-0
lines changed

itest/hot-reload/rust/src/lib.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ struct Reloadable {
2828
#[export]
2929
#[init(val = Planet::Earth)]
3030
favorite_planet: Planet,
31+
32+
#[init(val = NoDefault::obtain())]
33+
_other_object: Gd<NoDefault>,
3134
}
3235

3336
#[godot_api]
@@ -41,10 +44,24 @@ impl Reloadable {
4144
fn from_string(s: GString) -> Gd<Self> {
4245
Gd::from_object(Reloadable {
4346
favorite_planet: Planet::from_godot(s),
47+
_other_object: NoDefault::obtain(),
4448
})
4549
}
4650
}
4751

52+
// no_init reloadability - https://github.com/godot-rust/gdext/issues/874.
53+
#[derive(GodotClass)]
54+
#[class(no_init, base=Node)]
55+
struct NoDefault {}
56+
57+
#[godot_api]
58+
impl NoDefault {
59+
#[func]
60+
fn obtain() -> Gd<Self> {
61+
Gd::from_object(NoDefault {})
62+
}
63+
}
64+
4865
// ----------------------------------------------------------------------------------------------------------------------------------------------
4966

5067
#[derive(GodotConvert, Var, Export)]

0 commit comments

Comments
 (0)