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

Method array_value_or_set

src/cst/mod.rs:1270–1278  ·  view source on GitHub ↗

Gets the root value if it's an object or sets the root value as an object. Note: Use `.array_value_or_create()` to not overwrite the root value when it's not an object.

(&self)

Source from the content-addressed store, hash-verified

1268 /// Note: Use `.array_value_or_create()` to not overwrite the root value
1269 /// when it's not an object.
1270 pub fn array_value_or_set(&self) -> CstArray {
1271 match self.value() {
1272 Some(CstNode::Container(CstContainerNode::Array(node))) => node,
1273 _ => {
1274 self.set_value(CstInputValue::Array(Vec::new()));
1275 self.array_value().unwrap()
1276 }
1277 }
1278 }
1279
1280 /// Ensures this object's values use trailing commas.
1281 ///

Callers 1

or_set_methodsFunction · 0.80

Calls 10

ArrayClass · 0.85
valueMethod · 0.80
set_valueMethod · 0.80
array_valueMethod · 0.80
remove_rawMethod · 0.80
raw_insert_childMethod · 0.80
lenMethod · 0.80
childrenMethod · 0.80
appendMethod · 0.80
getMethod · 0.45

Tested by 1

or_set_methodsFunction · 0.64