#![cfg_attr(not(feature = "std"), no_std)]
#![no_implicit_prelude]
#![deny(missing_docs)]
#![allow(clippy::use_self, clippy::similar_names, clippy::cast_lossless, clippy::doc_markdown)]
#[cfg(feature = "alloc")] extern crate alloc;
#[cfg(not(any(unix, target_vendor = "apple")))]
compile_error!("snailx only supports Unix and macOS");
macro_rules! import {
($($v:tt)*) => {
#[cfg(feature = "std")]
use std::$($v)*;
#[cfg(not(feature = "std"))]
use core::$($v)*;
};
}
#[cfg_attr(feature = "__bench", macro_export)]
macro_rules! switch {
(core::$($v:tt)*) => {{
#[cfg(feature = "std")]
{
::std::$($v)*
}
#[cfg(not(feature = "std"))]
{
::core::$($v)*
}
}};
}
macro_rules! assume {
(!$e:expr) => {
if $e {
#[allow(unused_unsafe)]
unsafe {
switch!(core::hint::unreachable_unchecked(););
}
}
};
($e:expr) => {
if !$e {
#[allow(unused_unsafe)]
unsafe {
switch!(core::hint::unreachable_unchecked(););
}
}
};
(re, $e:expr) => {
assume!($e, "entered unreachable code");
};
(dbg, $e:expr, $($msg:tt)+) => {
#[cfg(debug_assertions)]
if !$e {
panic!($($msg)+);
}
};
(car, $exp:ident, $in_name:ident, $e:expr, $($msg:tt)+) => {
match $e {
$exp($in_name) => $in_name,
#[allow(unused_unsafe)]
_ => unsafe { switch!(core::hint::unreachable_unchecked();) },
}
};
($e:expr, $($msg:tt)+) => {
if !$e {
#[cfg(debug_assertions)]
{
panic!($($msg)+);
}
#[cfg(not(debug_assertions))]
#[allow(unused_unsafe)]
unsafe {
switch!(core::hint::unreachable_unchecked(););
}
}
};
}
pub mod direct;
mod ffi;
mod cmdline;
mod iter;
#[cfg(any(feature = "indexing_parser", feature = "non_indexing_parser"))] mod parser;
#[cfg(feature = "indexing_parser")] pub use parser::indexing as indexing_parser;
#[cfg(feature = "non_indexing_parser")] pub use parser::non_indexing as non_indexing_parser;
#[cfg(any(debug_assertions, not(feature = "assume_valid_str")))] mod str_checks;
pub use {
ffi::minimal_cstr::CStr,
iter::{args::*, mapped_args::*}
};
#[cfg(any(feature = "to_core_cstr", feature = "std"))]
pub use ffi::minimal_cstr::StdCStr;
#[cfg(feature = "__bench")]
#[allow(missing_docs)]
#[doc(hidden)]
pub mod bench_helpers {
pub use {cmdline::helpers::*, ffi::strlen, iter::helpers::len};
}