Skip to content

Commit 4540e39

Browse files
committed
Add OnEditor<T>, remove impl<T> Export for Gd<T> and DynGd<T, D>
- Doc tweaks.
1 parent 83649bb commit 4540e39

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

godot-core/src/obj/oneditor.rs

+5-8
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,15 @@ use crate::registry::property::{DirectExport, Export, Var};
1515
///
1616
/// Panics during access if uninitialized.
1717
/// When used inside a node class, `OnEditor` checks if a value has been set before `ready()` is run, and panics otherwise.
18-
///
19-
/// `OnEditor<T>` should always be used as a property, preferably in tandem with an `#[export]` or `#[var]`.
2018
/// Once initialized, it can be used almost as if it was a `T` value itself, due to `Deref`/`DerefMut` impls.
2119
///
22-
/// `OnEditor<T>` directly supports two workflows – setting given property via the Editor or doing so via code before the first use.
23-
/// The latter should be limited to use cases involving builder or factory patterns.
20+
/// `OnEditor<T>` should always be used as a property, preferably in tandem with an `#[export]` or `#[var]`.
21+
/// Initializing `OnEditor` values via code before the first use is supported but should be limited to use cases involving builder or factory patterns.
2422
///
2523
/// [`Option<Gd<T>>`](std::option) and [`OnReady<Gd<T>>`](crate::obj::onready::OnReady) should be used for any other late initialization logic.
2624
///
2725
/// # Using `OnEditor<T>` with `Gd<T>` and `DynGd<T, D>`
2826
///
29-
/// Exposing properties to the Godot editor is primary use of the `OnEditor<Gd<T>>`.
30-
///
3127
/// ## Example - auto-generated init
3228
///
3329
/// ```
@@ -129,8 +125,8 @@ use crate::registry::property::{DirectExport, Export, Var};
129125
/// #[derive(GodotClass)]
130126
/// #[class(init, base = Node)]
131127
/// struct SomeClassThatCanBeInstantiatedInCode {
132-
/// // Given initial value will be represented by `42` in the editor.
133-
/// // Will cause panic if not set via the editor or code.
128+
/// // Uninitialized value will be represented by `42` in the editor.
129+
/// // Will cause panic if not set via the editor or code before use.
134130
/// #[export]
135131
/// #[init(uninit = 42)]
136132
/// some_primitive: OnEditor<i64>,
@@ -146,6 +142,7 @@ use crate::registry::property::{DirectExport, Export, Var};
146142
///
147143
/// // Will not cause the panic.
148144
/// this.add_child(&my_node);
145+
///
149146
/// my_node
150147
/// }
151148
/// ```

0 commit comments

Comments
 (0)