Skip to main content

quote_key

Function quote_key 

Source
pub fn quote_key(key: &str) -> String
Expand description

Spell key as one bracket-quoted path segment, ["key"], that Value::get_path and every path-taking cst::Document method read back as exactly that mapping key. " and \ inside the key are escaped.

ยงExamples

use noyalib::path::quote_key;

assert_eq!(quote_key("app.kubernetes.io/name"), r#"["app.kubernetes.io/name"]"#);
assert_eq!(quote_key("*"), r#"["*"]"#);
assert_eq!(quote_key(r#"say "hi""#), r#"["say \"hi\""]"#);