Skip to main content

path

Macro path 

Source
macro_rules! path {
    () => { ... };
    ($($segment:expr),+ $(,)?) => { ... };
}
Expand description

Builds a Path from keys and indices: path!["spec", "containers", 0, "image"].

String-like segments (&str, String) are keys; integers are indices. A negative index names no item (it becomes usize::MAX).

use oneyaml_core::{path, Path};
let p = path!["spec", "ports", 2, "port"];
assert_eq!(p.to_string(), "spec.ports[2].port");
assert_eq!(path![], Path::new());