macro_rules! mem_set {
($memory_reference:ident $($rest:tt)*) => { ... };
(
@path_so_far { $path_so_far:expr }
@so_far { $reference_so_far:expr }
@rest [ $final_part_variable:expr ] = $value:expr
) => { ... };
(
@path_so_far { $path_so_far:expr }
@so_far { $reference_so_far:expr }
@rest . $final_part:ident = $value:expr
) => { ... };
(
@path_so_far { $path_so_far:expr }
@so_far { $reference_so_far:expr }
@rest [ $next_part_variable:expr ] $($rest:tt)+
) => { ... };
(
@path_so_far { $path_so_far:expr }
@so_far { $reference_so_far:expr }
@rest . $next_part:ident $($rest:tt)+
) => { ... };
($($not_valid:tt)*) => { ... };
}Expand description
Set a value in memory given a path, creating dicts for intermediate places if they do not exist.
Return
This macro produces a Result<(), ::screeps::memory::UnexpectedTypeError>. The error path will
trigger if any of the intermediate memory keys exist but are not dictionaries.
Examples
Set Memory.creeps.John.count to 42.
#[macro_use]
extern crate screeps;
let mem = screeps::memory::root();
mem_set!(mem.creeps.John.count = 42).unwrap();Set something using a variable path.
#[macro_use]
extern crate screeps;
let mem = screeps::memory::root();
let creep_name = "John";
let what_to_set = "count";
mem_set!(mem.creeps[creep_name][what_to_set] = 51).unwrap();
mem_set!(mem.creeps[creep_name].count = 52).unwrap();