Skip to content

Commit 1d950ad

Browse files
committed
pairing: remove impossible panic
Good to avoid panics, plus it save some bytes in the binary for code that never executes.
1 parent 588ca83 commit 1d950ad

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/rust/bitbox02-rust/src/workflow/pairing.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use alloc::string::String;
2121
pub fn format_hash(hash: &[u8; 32]) -> String {
2222
let mut encoded = [0u8; 60];
2323
let encoded = binascii::b32encode(&hash[..], &mut encoded).unwrap();
24-
// Base32 contains only utf-8 valid chars. unwrap is safe
25-
let encoded = core::str::from_utf8(encoded).expect("invalid utf-8");
24+
// Base32 contains only utf-8 valid chars.
25+
let encoded = unsafe { core::str::from_utf8_unchecked(encoded) };
2626
format!(
2727
"{} {}\n{} {}",
2828
&encoded[0..5],

0 commit comments

Comments
 (0)