aboutsummaryrefslogtreecommitdiff
path: root/src/util.rs
diff options
context:
space:
mode:
authorHimbeerserverDE <himbeerserverde@gmail.com>2023-11-13 14:06:28 +0100
committerHimbeerserverDE <himbeerserverde@gmail.com>2023-11-13 14:06:28 +0100
commitac992e085ace12ed3268f82f02ee97af0321ea99 (patch)
tree25d923c2550aab6d42e32d70b87a066a0d2ba6a5 /src/util.rs
parent0ea1e08fa5b9ac52339d1c35a2995a00fdcf4413 (diff)
make hexdump infallible
Empty input now results in an empty output String.
Diffstat (limited to 'src/util.rs')
-rw-r--r--src/util.rs4
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> {