[][src]Macro im_rc::update_in

macro_rules! update_in {
    ($target:expr, $path:expr => $($tail:tt) => *, $value:expr ) => { ... };
    ($target:expr, $path:expr, $value:expr) => { ... };
}

Update a value inside multiple levels of data structures.

This macro takes a Vector, OrdMap or HashMap, a key or a series of keys, and a value, and returns the data structure with the new value at the location described by the keys.

If one of the keys in the path doesn't exist, the macro will panic.

Examples

let vec_inside_vec = vector![vector![1, 2, 3], vector![4, 5, 6]];

let expected = vector![vector![1, 2, 3], vector![4, 5, 1337]];

assert_eq!(expected, update_in![vec_inside_vec, 1 => 2, 1337]);