Skip to main content

utf8_values

Function utf8_values 

Source
pub fn utf8_values<'t, 'v>(
    values: Vec<Vec<u8>>,
    name: &'t str,
) -> Result<Vec<String>, Error<'t, 'v>>
Expand description

Convert every repeated value of one text field, reporting name for the first that is not UTF-8.

The shared body of what a generated build does per collecting text field: one loop in the binary rather than one per field. Converts element by element rather than with collect so the error can carry the value that failed rather than only that one did.

The empty case is answered here rather than in the shared loop, and this is what keeps sharing the loop free: a command at mise’s scale declares dozens of collecting fields and a command line names one or two of them, so most of these calls have nothing to convert. Testing that at the field costs a branch; reaching the loop to learn it costs the call.