Enum ElementType
pub enum ElementType {
Untyped,
Builtin(VariantType),
Class(ClassId),
ScriptClass(ElementScript),
}
Expand description
Dynamic type information of Godot arrays and dictionaries.
Used by Array::element_type()
, dictionary key/value type methods,
and other type introspection functionality.
While Rust’s type parameters provide compile-time type information, this method can give additional RTTI (runtime type information).
For example, Array<Gd<RefCounted>>
may store classes or scripts derived from RefCounted
.
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: ArrayElement,
pub fn of<T>() -> ElementTypewhere
T: ArrayElement,
Build element type info for a compile-time element T
.
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