mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-17 19:00:58 +00:00
style(core/rust): less expensive conversion from known good utf8 string
This commit is contained in:
parent
0fb66d3527
commit
0b4ccf45fc
@ -1,3 +1,4 @@
|
|||||||
|
use core::str;
|
||||||
use cstr_core::CStr;
|
use cstr_core::CStr;
|
||||||
|
|
||||||
use super::ffi;
|
use super::ffi;
|
||||||
@ -25,6 +26,6 @@ pub fn button_sequence_to_word(prefix: u16) -> Option<&'static str> {
|
|||||||
} else {
|
} else {
|
||||||
// SAFETY: On success, `button_sequence_to_word` should return a 0-terminated
|
// SAFETY: On success, `button_sequence_to_word` should return a 0-terminated
|
||||||
// UTF-8 string with static lifetime.
|
// 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()) })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user