pub fn check_sorted_opt_ary_and_sho_idx_ary_with(
opt_ary: &[Opt<'_>],
sho_idx_ary: &[(u8, usize)]
) -> bool
Expand description
Check sorted opt ary table and sorted sho idx ary table.
- opt_ary: must be sorted by long keyword. ex) “barn”
- sho_idx_ary: must be sorted short keyword. ex) b’b’
- return:
- true: ok
- false: illegal tables
Examples
#[cfg(feature = "option_argument")]
{
use flood_tide::check;
use flood_tide::{Arg, Lex, Opt, OptNum};
#[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]
let opt_ary = [
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]
let opt_ary_sho_idx = [(b'a',0),(b'b',1)];
assert!(check::check_sorted_opt_ary_and_sho_idx_ary_with(
&opt_ary,
&opt_ary_sho_idx
));
}