godot-rust / godot-rust/gdext

Deep copies taking into account Rust state (unlike `Node::duplicate()`)

Open
#695 9 comments 0 reactions 0 assignees View on GitHub
c: register feature
Dominant language
Rust
Stars
5.2k
Forks
312
Avg merge
11h 10m
Merged PRs (30d)
10

Description

Taking the docs as an example,
```rust
#[derive(GodotClass)]
#[derive(GodotClass)]
#[class(base=Node3D)]
struct Monster {
name: String,
hitpoints: i32,
base: Base,
}
```

Calling .duplicate() on an instance will correctly copy all the stuff that Godot knows about, but name and hitpoints will be their .init() values

It makes sense that it works this way to a certain degree, since duplicate() is a Godot engine thing, so .duplicate() just calls the Godot function without doing anything special for the gdext portions, but it was surprising to me, and may be to others

There should be a way to fully clone a node and its children including their Rust properties, without requiring that each Rust property is `#[var]`-compatible.

original Discord thread: https://discord.com/channels/723850269347283004/1236100168722681927

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.