mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 20:17:45 +00:00
Rename bytes to hex, allocate String with capacity.
This commit is contained in:
parent
ae01996066
commit
d338206a62
1 changed files with 6 additions and 4 deletions
|
@ -322,10 +322,12 @@ fn determine_regex(lines: &[String]) -> Option<(Regex, bool)> {
|
||||||
|
|
||||||
// Converts bytes to a hexadecimal string
|
// Converts bytes to a hexadecimal string
|
||||||
fn bytes_to_hex(bytes: &[u8]) -> String {
|
fn bytes_to_hex(bytes: &[u8]) -> String {
|
||||||
bytes.iter().fold(String::new(), |mut bytes, byte| {
|
bytes
|
||||||
write!(bytes, "{byte:02x}").unwrap();
|
.iter()
|
||||||
bytes
|
.fold(String::with_capacity(bytes.len() * 2), |mut hex, byte| {
|
||||||
})
|
write!(hex, "{byte:02x}").unwrap();
|
||||||
|
hex
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_expected_checksum(
|
fn get_expected_checksum(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue