Rust std library collections wrapper that implements the godot-rust variant traits for convenience when using godot-rust.
Traits implemented on top of the standard library implementation:
Add this to your Cargo.toml
:
~~~toml gdvariants = "*" ~~~
Read the godot-rust book for information on how to setup a Godot project that uses Rust.
~~~rust use gdnative::api::; use gdnative::prelude::;
use gdvariants::collections::HashMap;
pub struct ExampleHashMapProperty {
#[property]
players: HashMap
~~~rust use gdnative::api::; use gdnative::prelude::;
use gdvariants::collections::HashMap;
...
fn send_data(&mut self, owner: &Node) {
let mut data: HashMap
for player in self.players.keys() {
owner.rpc_id(*player, "data", &[data.to_variant()]);
}
} ~~~
~~~rust use gdnative::api::; use gdnative::prelude::;
use gdvariants::collections::HashMap;
...
fn receive_data(&mut self, owner: &Node, data: HashMap
for player in self.players.keys() {
owner.rpc_id(*player, "data", &[data.to_variant()]);
}
} ~~~