Don't crash when failing to decode using StrRef codec

This commit is contained in:
Loïc Lecrenier 2022-09-21 14:39:43 +02:00 committed by Loïc Lecrenier
parent d0109627b9
commit 0ade699873

View File

@ -16,7 +16,7 @@ impl<'a> BytesDecode<'a> for StrRefCodec {
type DItem = &'a str;
fn bytes_decode(bytes: &'a [u8]) -> Option<Self::DItem> {
let s = std::str::from_utf8(bytes).unwrap();
let s = std::str::from_utf8(bytes).ok()?;
Some(s)
}
}