Skip to main content

value_length

Function value_length 

Source
pub fn value_length(value: &Value) -> i64
Expand description

Length of a value for ${#…}: element count for a list, key count for a record, and the CHARACTER count (Unicode scalar values) of the string form for any scalar (unchanged for non-collections). The single source of truth for every ${#…} evaluation site — the two sync ones, the two async ones in kernel.rs, and the two reduced-sync ones in scheduler/pipeline.rs — all of which reach it through resolve_length.

Characters, not bytes, so ${#v} agrees with slicing (classify_slice in interpreter/scope.rs already slices by character) and with bash — v=日本語 is length 3, not the 9-byte UTF-8 encoding. Non-string scalars stringify to ASCII (42, true, null), where chars and bytes coincide, so this is a no-op for them.