godot::prelude

Macro dict

macro_rules! dict {
    ($($key:tt: $value:expr),* $(,)?) => { ... };
}
Expand description

Constructs Dictionary literals, close to Godot’s own syntax.

Any value can be used as a key, but to use an expression you need to surround it in () or {}.

§Example

use godot::builtin::{dict, Variant};

let key = "my_key";
let d = dict! {
    "key1": 10,
    "another": Variant::nil(),
    key: true,
    (1 + 2): "final",
};

§See also

For arrays, similar macros array! and varray! exist.