Skip to content

Commit b7db212

Browse files
authored
Fixed '_owner' parameter in FAQ/EntityFactory (#70)
1 parent cd721b4 commit b7db212

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/faq/code.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ struct EntityFactory {}
216216
#[methods]
217217
impl EntityFactory {
218218
#[export]
219-
fn enemy(&self, _owner: &Object, name: String, health: f32)
219+
fn enemy(&self, _owner: &Reference, name: String, health: f32)
220220
-> Instance<Enemy, Unique> {
221221
Enemy { name, health }.emplace()
222222
}
@@ -286,12 +286,12 @@ impl AnotherNativeScript {
286286
.expect("Failed to convert my_node variant to object")
287287
.assume_safe()
288288
};
289-
289+
290290
// 2. Obtain a TInstance which gives access to the Rust object's data.
291291
let my_node = my_node
292292
.cast_instance::<MyNode2D>()
293293
.expect("Failed to cast my_node object to instance");
294-
294+
295295
// 3. Map over the RefInstance to process the underlying user data.
296296
my_node
297297
.map(|my_node, _owner| {
@@ -390,7 +390,7 @@ You would need to use the following code.
390390
#[no_constructor]
391391
struct MyNode {
392392
// late-initialization is modeled with Option
393-
// the Default derive will initialize both to None
393+
// the Default derive will initialize both to None
394394
node2d: Option<Ref<Node>>,
395395
instance: Option<Ref<MyClass>>,
396396
}
@@ -406,7 +406,7 @@ impl MyNode {
406406
let node2d = unsafe { node2d.assume_safe() };
407407
let node2d = node2d.cast::<Node2D>();
408408
self.node2d = Some(node2d.claim());
409-
409+
410410
// Get an existing child node that is a Rust class.
411411
let instance = owner
412412
.get_node("MyClass")

0 commit comments

Comments
 (0)