From 0b4ccf45fc5a7de9ccff48dd33c8458bff1d20c9 Mon Sep 17 00:00:00 2001 From: matejcik Date: Mon, 15 Aug 2022 15:01:13 +0200 Subject: [PATCH] style(core/rust): less expensive conversion from known good utf8 string --- core/embed/rust/src/trezorhal/slip39.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/embed/rust/src/trezorhal/slip39.rs b/core/embed/rust/src/trezorhal/slip39.rs index 7ccaba95b..6d061c885 100644 --- a/core/embed/rust/src/trezorhal/slip39.rs +++ b/core/embed/rust/src/trezorhal/slip39.rs @@ -1,3 +1,4 @@ +use core::str; use cstr_core::CStr; use super::ffi; @@ -25,6 +26,6 @@ pub fn button_sequence_to_word(prefix: u16) -> Option<&'static str> { } else { // SAFETY: On success, `button_sequence_to_word` should return a 0-terminated // UTF-8 string with static lifetime. - Some(unsafe { CStr::from_ptr(word).to_str().unwrap_unchecked() }) + Some(unsafe { str::from_utf8_unchecked(CStr::from_ptr(word).to_bytes()) }) } }