Function libherokubuildpack::toml::toml_select_value

source ·
pub fn toml_select_value<S: AsRef<str>, K: Deref<Target = [S]>>(
    keys: K,
    value: &Value
) -> Option<&Value>
Expand description

Selects a value at the given TOML path from a TOML value.

Works similarly to an xpath query to select a value inside a complex XML document. This function is useful to select a value from a TOML document without deserializing it into specific type which can sometimes be a complex endeavour.

Example:

use libherokubuildpack::toml::toml_select_value;
use toml::toml;

let toml = toml! {
    [config]
    [config.net]
    port = 12345
    host = "localhost"
};

assert_eq!(
    toml_select_value(vec!["config", "net", "port"], &toml.into()),
    Some(&toml::Value::from(12345))
);