Skip to main content

push_key

Function push_key 

Source
pub fn push_key(path: &mut String, key: &str)
Expand description

Append the mapping key key to path: in dot notation when the grammar reads the plain spelling back as that key, otherwise as the segment quote_key spells. A quoted segment needs no separator.

ยงExamples

use noyalib::path::push_key;

let mut path = String::from("items[0]");
push_key(&mut path, "labels");
push_key(&mut path, "app.kubernetes.io/name");
assert_eq!(path, r#"items[0].labels["app.kubernetes.io/name"]"#);