From 6a1ef090602fbba3bee8c7126c589e850e0dc945 Mon Sep 17 00:00:00 2001 From: Matti Viljanen Date: Sat, 25 May 2024 15:36:21 +0300 Subject: [PATCH] Use fewer unwraps Co-authored-by: Ruben De Smet --- libsignal-service/src/service_address.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libsignal-service/src/service_address.rs b/libsignal-service/src/service_address.rs index 7fbc41822..673cc9096 100644 --- a/libsignal-service/src/service_address.rs +++ b/libsignal-service/src/service_address.rs @@ -69,9 +69,9 @@ impl TryFrom<&[u8]> for ServiceAddress { type Error = ParseServiceAddressError; fn try_from(value: &[u8]) -> Result { - if value.starts_with(b"PNI:") { + if let Some(pni) = value.strip_prefix(b"PNI:") { Ok(ServiceAddress { - uuid: Uuid::from_slice(value.strip_prefix(b"PNI:").unwrap())?, + uuid: Uuid::from_slice(pni)?, identity: ServiceIdType::PhoneNumberIdentity, }) } else {