diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2026-03-04 20:31:24 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-04 20:31:24 +0100 |
| commit | 2a18c3b5841a8bd7ff1776c9801fd2d50e35ba10 (patch) | |
| tree | 485d5c22216869e18215d01caab0d5dd09f459bb /oryxc/src/errors.rs | |
| parent | ed3258836d0f4e806352ce60bec65a1ea26c8987 (diff) | |
| parent | ff258d9ce16fb99ef2fe3cfbae65634b98f782d2 (diff) | |
Merge pull request #1 from romirk/romirk/misc
vec supremacy
Diffstat (limited to 'oryxc/src/errors.rs')
| -rw-r--r-- | oryxc/src/errors.rs | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/oryxc/src/errors.rs b/oryxc/src/errors.rs index 290abc2..4ad88d6 100644 --- a/oryxc/src/errors.rs +++ b/oryxc/src/errors.rs @@ -12,7 +12,10 @@ use std::fmt::{ }; use std::io::Write; use std::path::Path; -use std::sync::OnceLock; +use std::sync::{ + LazyLock, + OnceLock, +}; use std::{ env, io, @@ -25,8 +28,9 @@ use crate::unicode; const TAB_AS_SPACES: &'static str = " "; const TABSIZE: usize = TAB_AS_SPACES.len(); -#[derive(Clone, Copy, Default, Eq, PartialEq)] +#[derive(Clone, Copy, Default, Eq, PartialEq, clap::ValueEnum)] pub enum ErrorStyle { + #[value(name = "oneline")] OneLine, #[default] Standard, @@ -35,12 +39,12 @@ pub enum ErrorStyle { pub static ERROR_STYLE: OnceLock<ErrorStyle> = OnceLock::new(); pub fn progname() -> &'static OsString { - static ARGV0: OnceLock<OsString> = OnceLock::new(); - return ARGV0.get_or_init(|| { + static ARGV0: LazyLock<OsString> = LazyLock::new(|| { let default = OsStr::new("oryxc"); let s = env::args_os().next().unwrap_or(default.into()); - return Path::new(&s).file_name().unwrap_or(default).to_os_string(); + Path::new(&s).file_name().unwrap_or(default).to_os_string() }); + &ARGV0 } #[macro_export] |