base: Simplify decode_key_value

master
Kévin Commaille 2021-05-25 10:26:56 +02:00
parent 64b5298881
commit a889bb3aca
No known key found for this signature in database
GPG Key ID: 296D60AE1E61661C
1 changed files with 1 additions and 5 deletions

View File

@ -161,11 +161,7 @@ impl EncodeKey for EventType {
pub fn decode_key_value(key: &[u8], position: usize) -> Option<String> {
let values: Vec<&[u8]> = key.split(|v| *v == ENCODE_SEPARATOR).collect();
if position >= values.len() {
return None;
}
Some(String::from_utf8_lossy(values[position]).to_string())
values.get(position).map(|s| String::from_utf8_lossy(s).to_string())
}
#[derive(Clone)]