use core::{
ffi::{c_char, CStr},
fmt::Debug,
ops::Deref,
};
#[repr(transparent)]
pub struct Arg(*const c_char);
impl Debug for Arg {
#[inline]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.deref().fmt(f)
}
}
impl From<&'static CStr> for Arg {
#[inline]
fn from(arg: &'static CStr) -> Self {
Self(arg.as_ptr())
}
}
impl Deref for Arg {
type Target = CStr;
#[inline]
fn deref(&self) -> &Self::Target {
unsafe { CStr::from_ptr(self.0) }
}
}
static mut ARGV: &'static [Arg] = &[];
#[inline]
pub fn argv() -> &'static [Arg] {
unsafe { ARGV }
}
#[doc(hidden)]
#[inline]
pub unsafe fn set_argv(argv: &'static [Arg]) {
ARGV = argv
}