dev: reduce build sizes (especially debug)
This commit is contained in:
26
src/utils.rs
26
src/utils.rs
@@ -37,3 +37,29 @@ pub mod web {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub mod shasum {
|
||||
#[must_use]
|
||||
pub fn sha256sum_to_hex_string(sha256sum: &[u8]) -> String {
|
||||
let mut out = String::with_capacity(sha256sum.len() * 2);
|
||||
|
||||
for &b in sha256sum {
|
||||
/// Only correct as long as `n` is ranged within a nibble
|
||||
#[inline]
|
||||
const fn nibble_to_hex(n: u8) -> char {
|
||||
(match n {
|
||||
0..=9 => b'0' + n,
|
||||
_ => b'a' + (n - 10),
|
||||
}) as char
|
||||
}
|
||||
|
||||
let hi = (b >> 4) & 0x0f;
|
||||
let lo = b & 0x0f;
|
||||
|
||||
out.push(nibble_to_hex(hi));
|
||||
out.push(nibble_to_hex(lo));
|
||||
}
|
||||
|
||||
out
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user