Removed one unneeded unsafe block

This commit is contained in:
Dennis Schwerdel 2019-12-05 18:29:12 +01:00
parent 8fcd800d56
commit 70109eeb51
1 changed files with 4 additions and 4 deletions

View File

@ -25,12 +25,12 @@ pub type Time = i64;
const HEX_CHARS: &[u8] = b"0123456789abcdef"; const HEX_CHARS: &[u8] = b"0123456789abcdef";
pub fn bytes_to_hex(bytes: &[u8]) -> String { pub fn bytes_to_hex(bytes: &[u8]) -> String {
let mut v = Vec::with_capacity(bytes.len() * 2); let mut s = String::with_capacity(bytes.len() * 2);
for &byte in bytes { for &byte in bytes {
v.push(HEX_CHARS[(byte >> 4) as usize]); s.push(HEX_CHARS[(byte >> 4) as usize] as char);
v.push(HEX_CHARS[(byte & 0xf) as usize]); s.push(HEX_CHARS[(byte & 0xf) as usize] as char);
} }
unsafe { String::from_utf8_unchecked(v) } s
} }