ObjectToOwned

Trait ObjectToOwned 

pub trait ObjectToOwned<T>
where T: GodotClass,
{ // Required method fn object_to_owned(&self) -> Gd<T>; }
Expand description

Obtain owned Gd from either &self or &Gd.

This trait allows passing either Gd<T> or C (where C: WithBaseField) to functions that need an owned Gd<T>.

This is primarily used for signal connection methods in TypedSignal and ConnectBuilder, where you can pass either a &Gd (outside) or &SomeClass (from within impl block) as the receiver object.

§Similar traits

  • UniformObjectDeref provides unified dereferencing of user and engine classes.
  • AsArg enables general argument conversions for Godot APIs.

Required Methods§

fn object_to_owned(&self) -> Gd<T>

Converts the object reference to an owned Gd<T>.

Implementors§

§

impl<C> ObjectToOwned<C> for C
where C: WithBaseField,

§

impl<T> ObjectToOwned<T> for Gd<T>
where T: GodotClass,