#![doc = include_str!("../README.md")]
#[doc(hidden)]
#[macro_export]
macro_rules! use_args {
($($using_ident: ident), *) => {
{
$(
let __suppress_unused_warning = $using_ident;
)*
};
};
}
#[macro_export]
macro_rules! todo_using {
($(using=)?[$($using_ident: ident),* $(,)?], unimplemented($($message_arg:tt)+)) => {
$crate::use_args!($($using_ident), *);
core::todo!($($message_arg)+);
};
($(using=)?[$($using_ident: ident),* $(,)?], $($message_arg:tt)*) => {
$crate::use_args!($($using_ident), *);
core::todo!($($message_arg)*);
};
($(using=)?[$($using_ident: ident),* $(,)?]) => {
$crate::use_args!($($using_ident), *);
core::todo!();
};
($($using_ident: ident),* $(,)?) => {
$crate::use_args!($($using_ident), *);
core::todo!();
};
}
#[cfg(test)]
mod tests {
use std::{panic::UnwindSafe, fmt::Debug};
use super::*;
fn capture_panic_message<R: Debug>(panicking_closure: impl FnOnce() -> R + UnwindSafe) -> String {
*std::panic::catch_unwind(panicking_closure).unwrap_err().downcast::<String>().unwrap()
}
#[test]
fn panics_match() {
#[allow(unused_variables)]
let arg1 = 5;
let arg2 = "some String";
let format_arg = "IDK what to put here";
assert_eq!(
capture_panic_message(||{todo_using!(using = [arg1, arg2], unimplemented("Unimplemented Code {}", format_arg));}),
capture_panic_message(||{todo_using!([arg1, arg2], "Unimplemented Code {}", format_arg);}),
);
}
}