summaryrefslogtreecommitdiff
path: root/oryxc
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2026-03-04 02:00:50 +0100
committerThomas Voss <mail@thomasvoss.com> 2026-03-04 02:00:50 +0100
commitb42324032ef7958fdb26b4c332dbc3c779ee3573 (patch)
treeba55dca9551890312d59cdb2fc5d0ed43f2e3269 /oryxc
parentafe584112893313b3d4aec71d11c471b66dbfff5 (diff)
Remove use of unwrap()
Diffstat (limited to 'oryxc')
-rw-r--r--oryxc/src/main.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/oryxc/src/main.rs b/oryxc/src/main.rs
index 23fa66b..7a0b0a8 100644
--- a/oryxc/src/main.rs
+++ b/oryxc/src/main.rs
@@ -7,6 +7,7 @@ mod parser;
mod size;
mod unicode;
+use std::borrow::Cow;
use std::ffi::OsString;
use std::{
env,
@@ -40,11 +41,15 @@ impl Flags {
Short('l') | Long("debug-lexer") => flags.debug_lexer = true,
Short('p') | Long("debug-parser") => flags.debug_parser = true,
Short('s') | Long("error-style") => {
- /* TODO: Don’t unwrap */
- flags.error_style = match parser.value()?.to_str().unwrap() {
- "oneline" => errors::ErrorStyle::OneLine,
- "standard" => errors::ErrorStyle::Standard,
- s => Err(format!("{s}: invalid value for -s/--error-style"))?,
+ flags.error_style = match parser.value()?.to_string_lossy()
+ {
+ Cow::Borrowed("oneline") => errors::ErrorStyle::OneLine,
+ Cow::Borrowed("standard") => {
+ errors::ErrorStyle::Standard
+ },
+ s => Err(format!(
+ "{s}: invalid value for -s/--error-style"
+ ))?,
};
},
Short('t') | Long("threads") => {