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 as false and 1/true as true.
A helper function to determine the relative path to path from base.
Given a key path key of the form a.b.c, creates nested dictionaries for for every path component delimited by . in the path string (3 in a.b.c), each a parent of the next, and the leaf mapping to value (a -> b -> c -> value).