Enum ElementType
pub enum ElementType {
Untyped,
Builtin(VariantType),
Class(ClassId),
ScriptClass(ElementScript),
}Expand description
Dynamic type information of Godot arrays and dictionaries.
Used in the following APIs:
While Rust’s type parameters and the Element trait in particular provide compile-time type information, this method exists for the
purpose of RTTI (runtime type information). For example, AnyArray (which offers no static type) can be queried about the actual type of
its elements.
Variants§
Untyped
Untyped array/dictionary that can contain any Variant.
Builtin(VariantType)
Typed array with built-in type (e.g., Array<i64>, Array<GString>).
Class(ClassId)
Typed array with class (e.g., Array<Gd<Node3D>>, Array<Gd<Resource>>).
ScriptClass(ElementScript)
Typed array with a script-based class (e.g. GDScript class Enemy).
Arrays of this element type cannot be created directly in Rust code. They come into play when you have a GDScript with
class_name MyClass, and then create a typed Array[MyClass] in GDScript. In Rust, these arrays can be represented with
their native base class (the one mentioned in extends in GDScript), e.g. Array<Gd<RefCounted>>.
Implementations§
§impl ElementType
impl ElementType
pub fn of<T>() -> ElementTypewhere
T: Element,
pub fn of<T>() -> ElementTypewhere
T: Element,
Build element type info for a compile-time element T.
pub fn is_typed(&self) -> bool
pub fn is_typed(&self) -> bool
True if this denotes a typed array/dictionary element.
Variant is considered untyped, every other type is typed.
pub fn variant_type(&self) -> VariantType
pub fn variant_type(&self) -> VariantType
The VariantType corresponding to this element type.
pub fn class_id(&self) -> Option<ClassId>
pub fn class_id(&self) -> Option<ClassId>
The class ID, if this type is of type Class or ScriptClass.
Trait Implementations§
§impl Clone for ElementType
impl Clone for ElementType
§fn clone(&self) -> ElementType
fn clone(&self) -> ElementType
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more