in rust/ccommon-backend/src/option/parse.rs [273:302]
fn parse_kv<'a>(input: &'a [u8], line: u32) -> Result<(&'a [u8], &'a [u8]), ParseError<'a>> {
let mut first = true;
let mut split = input.split(|&x| {
if x == b':' && first {
first = false;
return true;
}
false
});
let key = match split.next() {
Some(x) => x,
// There will always be at least one subslice
None => unreachable!(),
};
let value = match split.next() {
Some(x) => x,
None => return Err(ParseError::missing_colon(Span::new(input, line))),
};
let key = trim_bytes(key);
if !is_valid_name(key) {
return Err(ParseError::invalid_key(Span::new(key, line)));
}
Ok((key, trim_bytes(value)))
}