[−][src]Struct flood_tide::Lex
Lexical analyzer
this is analyzing command line arguments, returning tokens.
Examples
#[cfg(not(feature = "long_only"))] #[cfg(feature = "option_argument")] { use flood_tide::{Arg, Lex, Opt, OptNum}; #[rustfmt::skip] let args = ["-ab", "--barn", "--eat", "jum"]; #[rustfmt::skip] #[repr(u8)] #[derive(Debug, PartialEq)] enum CmdOP { A = 1, Barn, Eat, }; impl CmdOP { pub const fn to(self) -> OptNum { self as OptNum } } #[rustfmt::skip] const OPT_ARY: [Opt;3] = [ Opt { sho: b'a', lon: "", has: Arg::No, num: CmdOP::A.to(), }, Opt { sho: b'b', lon: "barn", has: Arg::No, num: CmdOP::Barn.to(), }, Opt { sho: 0u8, lon: "eat", has: Arg::Yes, num: CmdOP::Eat.to(), }, ]; #[rustfmt::skip] const OPT_ARY_SHO_IDX: [(u8,usize);2] = [(b'a',0),(b'b',1)]; let lex = Lex::create_with(&OPT_ARY, &OPT_ARY_SHO_IDX); let tokens = match lex.tokens_from(&args) { Ok(t) => t, Err(e) => unreachable!(), }; }
Implementations
impl<'a> Lex<'a>
[src]
pub fn create_with(
opt_ary: &'a [Opt<'_>],
sho_idx_ary: &'a [(u8, usize)]
) -> Lex<'a>
[src]
opt_ary: &'a [Opt<'_>],
sho_idx_ary: &'a [(u8, usize)]
) -> Lex<'a>
create lexical analyzer
pub fn subcmd(mut self: Self, subcmd_ary: &'a [&'a str]) -> Self
[src]
setup subcommand ary
pub fn tokens_from(&'a self, args: &'a [&'a str]) -> Result<Tokens<'a>, OPErr>
[src]
analyze and return tokens
Trait Implementations
Auto Trait Implementations
impl<'a> RefUnwindSafe for Lex<'a>
[src]
impl<'a> Send for Lex<'a>
[src]
impl<'a> Sync for Lex<'a>
[src]
impl<'a> Unpin for Lex<'a>
[src]
impl<'a> UnwindSafe for Lex<'a>
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,