From 0ade6998735e943dcaba9844814556d858a93319 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Lecrenier?= Date: Wed, 21 Sep 2022 14:39:43 +0200 Subject: [PATCH] Don't crash when failing to decode using StrRef codec --- milli/src/heed_codec/facet/str_ref.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/milli/src/heed_codec/facet/str_ref.rs b/milli/src/heed_codec/facet/str_ref.rs index 36e702627..ced5cc65e 100644 --- a/milli/src/heed_codec/facet/str_ref.rs +++ b/milli/src/heed_codec/facet/str_ref.rs @@ -16,7 +16,7 @@ impl<'a> BytesDecode<'a> for StrRefCodec { type DItem = &'a str; fn bytes_decode(bytes: &'a [u8]) -> Option { - let s = std::str::from_utf8(bytes).unwrap(); + let s = std::str::from_utf8(bytes).ok()?; Some(s) } }