macro_rules! get_in {
($target:expr, $path:expr => $($tail:tt) => * ) => { ... };
($target:expr, $path:expr) => { ... };
}
Expand description
Get a value inside multiple levels of data structures.
This macro takes a Vector
, OrdMap
or HashMap
,
along with a key or a series of keys, and returns the value at the location inside
the data structure described by the key sequence, or None
if any of the keys didn’t
exist.
Examples
let vec_inside_vec = vector![vector![1, 2, 3], vector![4, 5, 6]];
assert_eq!(Some(&6), get_in![vec_inside_vec, 1 => 2]);