From a889bb3acaf6679140b9a6019efc3d39748c7851 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Commaille?= Date: Tue, 25 May 2021 10:26:56 +0200 Subject: [PATCH] base: Simplify decode_key_value --- matrix_sdk_base/src/store/sled_store/mod.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/matrix_sdk_base/src/store/sled_store/mod.rs b/matrix_sdk_base/src/store/sled_store/mod.rs index 8f474d60..a5451444 100644 --- a/matrix_sdk_base/src/store/sled_store/mod.rs +++ b/matrix_sdk_base/src/store/sled_store/mod.rs @@ -161,11 +161,7 @@ impl EncodeKey for EventType { pub fn decode_key_value(key: &[u8], position: usize) -> Option { 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)]