Skip to main content

sequence_str_values

Function sequence_str_values 

Source
pub fn sequence_str_values(sequence: &Sequence) -> Vec<&str>
Expand description

Collect the string-shaped values of a serde_yaml::Sequence as borrowed &str slices — the sequence-values-axis peer of mapping_str_keys on the mapping-keys-axis. The three-line composition

let values: Vec<&str> = <sequence>
    .iter()
    .filter_map(|v| v.as_str())
    .collect();

three routed test-side call sites (the caixa-mesh per- placement.clusters cluster-name-list readback + the two per- GATEWAY_API_KEY_HOSTNAMES plural HTTPRoute hostname-list readbacks) previously threaded around the same one-token semantic concern mapping_str_keys closes on the sibling mapping-keys axis: “give me every string-shape scalar entry of this sequence as borrowed &str slices, in the sequence’s natural iteration order”. The lift collapses the three-token composition — the .iter() receiver-widen, the per-entry .filter_map(|v| v.as_str()) shape gate, the terminal .collect::<Vec<&str>>() type-witness — onto one accessor the caller reads as intent (sequence_str_values(<sequence>) — “give me every string scalar in this sequence”).

Structural peer to mapping_str_keys on the sibling mapping-keys enumeration axis at the same borrowed-Vec<&str> ownership altitude — the two together bracket the “flatten a YAML container of string scalars into a borrowed Vec<&str> snapshot” surface at both container-shape arms: mapping_str_keys closes it on serde_yaml::Mapping keys, sequence_str_values closes it on serde_yaml::Sequence values. Same ownership arity, same drop- not-panic contract, different container-shape input — the two scalar-enumeration axes the emit-side test-harness routinely reaches for when byte-comparing a readback of a K8s CR sub-container against an expected vec![<STR_CONST>, ...] shape.

Non-string-shape entries (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_str_keys enforces on non-string keys. The dropped entries never reach the downstream K8s YAML-scalar surface (which requires string scalars at every enumerated axis this helper serves — cluster-name list, hostname list, protocol list, endpoint list) anyway, so their absence from the yielded Vec<&str> mirrors the runtime shape the routed assert_eq!(..., vec![<STR_CONST>, ...]) byte-compare protects.

The owned Vec<String> altitude is a future companion lift on the same axis if a routed caller ever needs to interpolate the yielded slice through a format!-like macro whose lifetime outlives the input sequence’s borrow — the same paired-arity carveout the sibling mapping_string_keys + mapping_str_keys pair already established on the mapping-keys enumeration axis.