aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2023-08-12 11:39:46 +0200
committerThomas Voss <mail@thomasvoss.com> 2023-08-12 11:39:46 +0200
commit11367850b9ef7d17f2691fe970c77602fe2b2f31 (patch)
treee62743003a9335f8b5727263edaf8f651adc24a4
parent15df372bd17eb11137d4ffc745bfdb3cdbabed6b (diff)
Update cerm to v1.1.1
-rw-r--r--Cargo.lock4
-rw-r--r--Cargo.toml2
-rw-r--r--src/main.rs34
3 files changed, 11 insertions, 29 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 5fc2540..46d83e7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -22,9 +22,9 @@ checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
[[package]]
name = "cerm"
-version = "1.0.0"
+version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ae70b99554a0c7adb21b4792c6809f49692db19a904ad0c05fb7092645b26716"
+checksum = "d3aa64404e5a9966b1335945be9183a38f38ebf8b18148182c88e5633bfb335c"
[[package]]
name = "cfg-if"
diff --git a/Cargo.toml b/Cargo.toml
index 262e69a..8d3427c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -10,7 +10,7 @@ authors = [
]
[dependencies]
-cerm = "1.0.0"
+cerm = "1.1.1"
itertools = "0.11.0"
lexopt = "0.1.0"
tempfile = "3.7.0"
diff --git a/src/main.rs b/src/main.rs
index c391320..c0121c9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -14,7 +14,7 @@ use std::{
use itertools::Itertools;
use {
- cerm::{err, warn},
+ cerm::{err, require, warn},
tempfile::tempdir,
};
@@ -64,9 +64,7 @@ fn usage(bad_flags: Option<lexopt::Error>) -> ! {
}
fn main() {
- if let Err(e) = work() {
- err!("{e}");
- }
+ require!(work())
}
fn work() -> Result<(), io::Error> {
@@ -79,20 +77,14 @@ fn work() -> Result<(), io::Error> {
/* Collect sources from standard input */
let srcs = io::stdin()
.bytes()
- .map(|x| {
- x.unwrap_or_else(|e| {
- err!("{e}");
- })
- })
+ .map(|x| require!(x))
.group_by(|b| is_terminal(&flags, b));
let srcs = srcs
.into_iter()
.filter(|(x, _)| !x)
.map(|(_, x)| String::from_utf8(x.collect_vec()))
- .collect::<Result<Vec<_>, _>>()
- .unwrap_or_else(|e| {
- err!("{e}");
- });
+ .collect::<Result<Vec<_>, _>>();
+ let srcs = require!(srcs);
let mut dsts = Vec::with_capacity(srcs.len());
if flags.individual {
@@ -135,11 +127,7 @@ fn work() -> Result<(), io::Error> {
Ok((s, t, d))
}
})
- .map(|x| {
- x.unwrap_or_else(|e| {
- err!("{e}");
- })
- })
+ .map(|x| require!(x))
.sorted_by_key(|s| Reverse(s.0.components().count()))
.collect_vec();
@@ -263,11 +251,7 @@ fn run_multi(
});
let groups = co
.bytes()
- .map(|x| {
- x.unwrap_or_else(|e| {
- err!("{e}");
- })
- })
+ .map(|x| require!(x))
.group_by(|b| is_terminal(flags, b));
groups
.into_iter()
@@ -276,9 +260,7 @@ fn run_multi(
false => Some(y),
})
.for_each(|x| {
- let dst = String::from_utf8(x.collect_vec()).unwrap_or_else(|e| {
- err!("{e}");
- });
+ let dst = require!(String::from_utf8(x.collect_vec()));
dsts.push(if flags.encode {
decode_string(&dst)
} else {