MCPcopy Create free account
hub / github.com/dprint/jsonc-parser / or_create_methods

Function or_create_methods

src/cst/mod.rs:3949–3965  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3947
3948 #[test]
3949 fn or_create_methods() {
3950 let cst = build_cst("");
3951 let obj = cst.object_value_or_create().unwrap();
3952 assert_eq!(cst.to_string(), "{}\n");
3953 assert!(cst.array_value_or_create().is_none());
3954 assert_eq!(obj.object_value_or_create("prop").unwrap().to_string(), "{}");
3955 assert!(obj.array_value_or_create("prop").is_none());
3956 assert_eq!(obj.array_value_or_create("prop2").unwrap().to_string(), "[]");
3957 assert_eq!(
3958 cst.to_string(),
3959 r#"{
3960 "prop": {},
3961 "prop2": []
3962}
3963"#
3964 );
3965 }
3966
3967 #[test]
3968 fn or_set_methods() {

Callers

nothing calls this directly

Calls 2

build_cstFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…