diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-13 14:06:28 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-11-13 14:06:28 +0100 |
commit | ac992e085ace12ed3268f82f02ee97af0321ea99 (patch) | |
tree | 25d923c2550aab6d42e32d70b87a066a0d2ba6a5 /src/util.rs | |
parent | 0ea1e08fa5b9ac52339d1c35a2995a00fdcf4413 (diff) |
make hexdump infallible
Empty input now results in an empty output String.
Diffstat (limited to 'src/util.rs')
-rw-r--r-- | src/util.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/util.rs b/src/util.rs index e226ca6..7b3517f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -48,12 +48,12 @@ pub fn inform() { } } -pub fn hexdump<A: AsRef<[u8]>>(data: A) -> Result<String> { +pub fn hexdump<A: AsRef<[u8]>>(data: A) -> String { data.as_ref() .iter() .map(|byte| format!("{:02x}", byte)) .reduce(|acc, ch| acc + &ch) - .ok_or(Error::NoData) + .unwrap_or(String::new()) } pub fn sys_to_instant(sys: SystemTime) -> Result<Instant> { |