diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-12 15:19:58 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-12 15:19:58 +0100 |
commit | e1d532a4371fe607b7ee490a4e992a8760017510 (patch) | |
tree | 49932d26a15ed3469897961e3ad8a2d62d07d5aa | |
parent | 97d3e07ab4f00c0d6c555a03730278a0ec7c937e (diff) |
hexdump(): accept any AsRef<[u8]> implementor
-rw-r--r-- | src/util.rs | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/util.rs b/src/util.rs index d95a005..f7fc315 100644 --- a/src/util.rs +++ b/src/util.rs @@ -45,8 +45,9 @@ pub fn inform() { } } -pub fn hexdump(data: &[u8]) -> Result<String> { - data.iter() +pub fn hexdump<A: AsRef<[u8]>>(data: A) -> Result<String> { + data.as_ref() + .iter() .map(|byte| format!("{:02x}", byte)) .reduce(|acc, ch| acc + &ch) .ok_or(Error::NoData) |