array

Macro array 

macro_rules! array {
    ($($elements:expr),* $(,)?) => { ... };
}
Expand description

Constructs Array literals, similar to Rust’s standard vec! macro.

§Type inference

To create an Array<E>, the types of the provided values T must implement AsArg<E>.

For values that can directly be represented in Godot (implementing GodotType), types can usually be inferred. You need to respect by-value vs. by-reference semantics as per ToGodot::Pass.

§Examples

// Inferred type - i32: AsArg<i32>
let ints = array![3, 1, 4];

// Inferred type - &GString: AsArg<GString>
let strs = array![&GString::from("godot-rust")];

// Explicitly specified type - &str: AsArg<GString>
let strs: Array<GString> = array!["Godot", "Rust"];

§See also

To create an Array of variants, see the varray! macro.

For dictionaries, a similar macro vdict! exists.