pub trait WithDeferredCall<T: GodotClass> {
// Required method
fn apply_deferred<F>(&mut self, rust_function: F)
where F: FnOnce(&mut T) + 'static;
}
Expand description
Enables Gd::apply_deferred()
for type-safe deferred calls.
The trait is automatically available for all engine-defined Godot classes and user classes containing a Base<T>
field.
§Usage
fn some_fn(mut node: Gd<Node2D>) {
node.apply_deferred(|n: &mut Node2D| n.rotate(PI))
}
Required Methods§
Sourcefn apply_deferred<F>(&mut self, rust_function: F)
fn apply_deferred<F>(&mut self, rust_function: F)
Defers the given closure to run during idle time.
This is a type-safe alternative to Object::call_deferred()
.
§Panics
If called outside the main thread.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl<T, S, D> WithDeferredCall<T> for Swhere
T: UniformObjectDeref<D, Declarer = D>,
S: ToSignalObj<T>,
D: Declarer,
Available on
since_api="4.2"
only.