mirror of
https://github.com/shiroyashik/sculptor.git
synced 2025-12-06 13:01:12 +03:00
test code
This commit is contained in:
parent
6d26330bd8
commit
36b4a79a7e
1 changed files with 3 additions and 1 deletions
|
|
@ -23,7 +23,7 @@ pub fn bytes_into_string(code: &[u8]) -> String {
|
||||||
// code.iter().map(|byte| format!("{:02x}", byte)).collect::<String>() // ????? Why do you need this? Why not just String::from_utf8()??
|
// code.iter().map(|byte| format!("{:02x}", byte)).collect::<String>() // ????? Why do you need this? Why not just String::from_utf8()??
|
||||||
// So we need to turn each byte into a string with a 2-digit hexadecimal representation apparently...
|
// So we need to turn each byte into a string with a 2-digit hexadecimal representation apparently...
|
||||||
|
|
||||||
// hex::encode_to_slice(input, output)
|
let test_res = hex::encode(code);
|
||||||
|
|
||||||
let res = code.iter().fold(String::new(), |mut acc, byte| {
|
let res = code.iter().fold(String::new(), |mut acc, byte| {
|
||||||
acc.push_str(&format!("{:02x}", byte));
|
acc.push_str(&format!("{:02x}", byte));
|
||||||
|
|
@ -31,6 +31,8 @@ pub fn bytes_into_string(code: &[u8]) -> String {
|
||||||
}); // This is the same as the above, but with a fold instead of a map
|
}); // This is the same as the above, but with a fold instead of a map
|
||||||
|
|
||||||
|
|
||||||
|
tracing::debug!(?test_res, ?res, "bytes_into_string");
|
||||||
|
|
||||||
// Can we do this with hex::encode instead?
|
// Can we do this with hex::encode instead?
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue