Skip to main content

parse_inline_to_map

Function parse_inline_to_map 

Source
pub fn parse_inline_to_map(
    s: &str,
) -> Result<HashMap<String, String>, AamlError>
Expand description

Parses an inline object string { key = value, ... } into a HashMap<String, String>.

Nested structures (e.g. [a, b] inside values) are preserved as raw strings.

§Feature

Enabled by default under the builder-extras feature.

§Example

use aam_core::builder::parse_inline_to_map;

let map = parse_inline_to_map(r#"{ system = cmake, args = ["-G", "Ninja"] }"#).unwrap();
assert_eq!(map.get("system").unwrap(), "cmake");
assert_eq!(map.get("args").unwrap(), r#"["-G", "Ninja"]"#);