use std::num::NonZero;
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub struct ArgAttrs(pub u32);
impl ArgAttrs {
pub const fn index(i: u8) -> Self {
Self(i as u32)
}
#[must_use]
pub fn get_index(self) -> u8 {
self.0 as u8
}
pub const fn delimiter(ch: Option<NonZero<u8>>) -> Self {
let ch = match ch {
Some(ch) => ch.get(),
None => 0,
};
assert!(ch.is_ascii());
Self((ch as u32) << 8)
}
#[must_use]
pub fn get_delimiter(self) -> Option<NonZero<u8>> {
NonZero::new((self.0 >> 8) as u8)
}
pub const NO_VALUE: Self = Self(1 << 16);
pub const REQUIRE_EQ: Self = Self(1 << 17);
pub const ACCEPT_HYPHEN_ANY: Self = Self(1 << 18);
pub const ACCEPT_HYPHEN_NUM: Self = Self(1 << 19);
pub const GLOBAL: Self = Self(1 << 20);
pub const MAKE_LOWERCASE: Self = Self(1 << 21);
pub const GREEDY: Self = Self(1 << 22);
pub fn set(&mut self, other: Self, value: bool) {
if value {
self.0 |= other.0;
}
}
#[must_use]
pub const fn union(self, other: Self) -> Self {
Self(self.0 | other.0)
}
#[must_use]
pub const fn contains(self, other: Self) -> bool {
self.0 & other.0 == other.0
}
}