#[macro_use]
mod concat_assert;
#[cfg(feature = "non_basic")]
#[macro_use]
pub(crate) mod concat_macro;
#[cfg(feature = "non_basic")]
#[macro_use]
mod non_basic_macros;
#[cfg(feature = "non_basic")]
#[macro_use]
mod macro_utils;
#[cfg(feature = "non_basic")]
#[macro_use]
mod impl_panicfmt;
#[macro_use]
mod unwrapping;
#[doc(hidden)]
#[macro_export]
macro_rules! __write_array {
($array:expr, $len:expr, $value:expr) => {
$array[$len] = $value;
$len += 1;
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __write_array_checked {
($array:expr, $len:expr, $value:expr) => {
if $array.len() > $len {
$array[$len] = $value;
$len += 1;
}
};
}
#[doc = crate::doc_macros::limitation_docs!()]
#[cfg_attr(feature = "non_basic", doc = "```rust")]
#[cfg_attr(not(feature = "non_basic"), doc = "```ignore")]
#[macro_export]
macro_rules! coerce_fmt {
($reff:expr) => {
match &$reff {
reff => $crate::__::PanicFmt::PROOF.infer(reff).coerce(reff),
}
};
}
#[doc = formatting_docs!()]
#[doc = crate::doc_macros::limitation_docs!()]
#[macro_export]
macro_rules! concat_panic {
($($args:tt)*) => (
$crate::__concat_func_setup!{
(|args| $crate::concat_panic(args))
[]
[$($args)*,]
}
)
}
#[doc(hidden)]
#[macro_export]
macro_rules! __concat_func_setup {
($args:tt $prev:tt [$($fmt:tt).*; $($rem:tt)* ]) => ({
let mut fmt: $crate::FmtArg = $($fmt).*;
$crate::__concat_func!{fmt $args $prev [$($rem)*]}
});
($args:tt $prev:tt [$(:: $(@$_dummy:tt@)?)? $($fmt:ident)::* ; $($rem:tt)* ]) => ({
let mut fmt: $crate::FmtArg = $(:: $($_dummy)?)? $($fmt)::*;
$crate::__concat_func!{fmt $args $prev [$($rem)*]}
});
($args:tt $prev:tt $rem:tt) => ({
let mut fmt: $crate::FmtArg = $crate::FmtArg::DEBUG;
$crate::__concat_func!{fmt $args $prev $rem}
});
}
#[doc(hidden)]
#[macro_export]
macro_rules! __concat_func {
($fmt:ident $args:tt [$($prev:tt)*] [$keyword:tt: $expr:expr, $($rem:tt)* ]) => {
$crate::__concat_func!{
$fmt
$args
[$($prev)* ($crate::__set_fmt_from_kw!($keyword, $fmt), $expr)]
[$($rem)*]
}
};
($fmt:ident $args:tt [$($prev:tt)*] [$expr:literal, $($rem:tt)* ]) => {
$crate::__concat_func!{
$fmt
$args
[$($prev)* ($crate::__set_fmt_from_kw!(display, $fmt), $expr)]
[$($rem)*]
}
};
($fmt:ident $args:tt [$($prev:tt)*] [$expr:expr, $($rem:tt)* ]) => {
$crate::__concat_func!{
$fmt
$args
[$($prev)* ($fmt, $expr)]
[$($rem)*]
}
};
($fmt:ident (|$args:ident| $function_call:expr) [$(($fmt_arg:expr, $reff:expr))*] [$(,)*]) => {
match &[
$(
$crate::StdWrapper(
&$crate::coerce_fmt!($reff)
.to_panicvals($fmt_arg)
).deref_panic_vals(),
)*
] {
$args => $function_call,
}
};
}
#[doc(hidden)]
#[macro_export]
macro_rules! __set_fmt_from_kw {
(open, $fmtarg:ident) => {{
$fmtarg = $fmtarg.indent();
$fmtarg.set_display()
}};
(close, $fmtarg:ident) => {{
$fmtarg = $fmtarg.unindent();
$fmtarg.set_display()
}};
(display, $fmtarg:ident) => {
$fmtarg.set_display().set_alternate(false)
};
({}, $fmtarg:ident) => {
$fmtarg.set_display().set_alternate(false)
};
(alt_display, $fmtarg:ident) => {
$fmtarg.set_display().set_alternate(true)
};
({#}, $fmtarg:ident) => {
$fmtarg.set_display().set_alternate(true)
};
(debug, $fmtarg:ident) => {
$fmtarg.set_debug().set_alternate(false)
};
({?}, $fmtarg:ident) => {
$fmtarg.set_debug().set_alternate(false)
};
(alt_debug, $fmtarg:ident) => {
$fmtarg.set_debug().set_alternate(true)
};
({#?}, $fmtarg:ident) => {
$fmtarg.set_debug().set_alternate(true)
};
(hex, $fmtarg:ident) => {
$fmtarg.set_hex().set_alternate(false)
};
({X}, $fmtarg:ident) => {
$fmtarg.set_hex().set_alternate(false)
};
(alt_hex, $fmtarg:ident) => {
$fmtarg.set_hex().set_alternate(true)
};
({#X}, $fmtarg:ident) => {
$fmtarg.set_hex().set_alternate(true)
};
(bin, $fmtarg:ident) => {
$fmtarg.set_bin().set_alternate(false)
};
({b}, $fmtarg:ident) => {
$fmtarg.set_bin().set_alternate(false)
};
(alt_bin, $fmtarg:ident) => {
$fmtarg.set_bin().set_alternate(true)
};
({#b}, $fmtarg:ident) => {
$fmtarg.set_bin().set_alternate(true)
};
(_, $fmtarg:ident) => {
$fmtarg
};
($kw:tt, $fmtarg:ident) => {
compile_error!(concat!(
"unrecognized formatting specifier: ",
stringify!($kw),
"\n",
"expected one of:\n",
"- display/{}\n",
"- alt_display/{#}\n",
"- debug/{?}\n",
"- alt_debug/{#?}\n",
"- hex/{X}\n",
"- alt_hex/{#X}\n",
"- bin/{b}\n",
"- alt_bin/{#b}\n",
))
};
}