Skip to main content

mapping_str_keys

Function mapping_str_keys 

Source
pub fn mapping_str_keys(mapping: &Mapping) -> Vec<&str>
Expand description

Collect the string-shaped keys of a serde_yaml::Mapping as borrowed &str slices — the borrowed-arity peer of mapping_string_keys on the emit-side render-determinism assert axis (THEORY.md §V.2.7). The five routed test-side call sites — the caixa-mesh per-CNP metadata: alphabetical-iteration pin, the [caixa-core] yaml_string_mapping / label_selector per-BTreeMap alphabetical-iteration pins, and the two kube_resource_skeleton top-level + metadata: insertion-order pins — previously carried the three-line

let keys: Vec<&str> = <mapping>
    .iter()
    .filter_map(|(k, _)| k.as_str())
    .collect();

composition around the same one-token semantic concern the sibling mapping_string_keys closes at the owned-Vec<String> altitude: “give me every string-shape key of this mapping, in the mapping’s natural iteration order”. The two together partition the key-only enumeration axis at both ownership arities — the owned scalar for the assert-side {keys:?} interpolation whose lifetime must outlive the outer mapping borrow, the borrowed slice for the assert-side assert_eq!(keys, vec![<KEY_CONST>, ...]) byte-compare whose lifetime is bounded by the surrounding assert expression.

The borrowed altitude the paired docstring on mapping_string_keys named as a “future lift, one altitude down on the ownership-arity axis, if the routed caller surface ever grows dense enough on that receiver-arm to justify it” — landed here on the exact 5-site threshold the sibling docstring called out, mirroring the discipline the paired production-side string_keyed_entries borrowed-(&str, &Value) iterator carries on the sibling entry-arity axis.

Non-string-shape keys (serde_yaml::Value::Number / serde_yaml::Value::Bool / serde_yaml::Value::Mapping / serde_yaml::Value::Sequence / serde_yaml::Value::Null / serde_yaml::Value::Tagged arms) are silently dropped — the same drop-not-panic contract the sibling mapping_string_keys + string_keyed_entries pair enforces.