1 2 3 4
pub fn string_until_null(bytes: &[u8]) -> &str { let end = bytes.iter().position(|&b| b == 0).unwrap_or(bytes.len()); std::str::from_utf8(&bytes[..end]).unwrap_or("<invalid utf8>") }