Expand description
Useful functions and macros for writing figments.
§map! macro
The map! macro constructs a Map from key-value
pairs and is particularly useful during testing:
use figment::util::map;
let map = map! {
"name" => "Bob",
"age" => "100"
};
assert_eq!(map.get("name"), Some(&"Bob"));
assert_eq!(map.get("age"), Some(&"100"));
let map = map! {
100 => "one hundred",
23 => "twenty-three"
};
assert_eq!(map.get(&100), Some(&"one hundred"));
assert_eq!(map.get(&23), Some(&"twenty-three"));
Modules§
- vec_
tuple_ map - A helper to serialize and deserialize a map as a vector of
(key, value)pairs.
Functions§
- bool_
from_ str_ or_ int - A helper to deserialize
0/falseasfalseand1/trueastrue. - diff_
paths - A helper function to determine the relative path to
pathfrombase. - nest
- Given a key path
keyof the forma.b.c, creates nested dictionaries for for every path component delimited by.in the path string (3 ina.b.c), each a parent of the next, and the leaf mapping tovalue(a->b->c->value).