Module rocket_db_pools::figment::util
source · 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§
- A helper to serialize and deserialize a map as a vector of
(key, value)
pairs.
Functions§
- A helper to deserialize
0/false
asfalse
and1/true
astrue
. - A helper function to determine the relative path to
path
frombase
. - Given a key path
key
of 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
).