--- a/src/metaprogramming.rs Tue Apr 08 13:30:12 2025 -0500 +++ b/src/metaprogramming.rs Sun Apr 27 20:29:43 2025 -0500 @@ -9,21 +9,30 @@ /// maybe_ref!(ref, V) // ➡ &V /// maybe_ref!(noref, V) // ➡ V /// ``` -#[macro_export] macro_rules! maybe_ref { - (ref, $x:expr) => { &$x }; - (noref, $x:expr) => { $x }; - (ref, $x:ty) => { &$x }; - (noref, $x:ty) => { $x }; + (ref, $x:expr) => { + &$x + }; + (noref, $x:expr) => { + $x + }; + (ref, $x:ty) => { + &$x + }; + (noref, $x:ty) => { + $x + }; } /// Choose `a` if first argument is the literal `ref`, otherwise `b`. -#[macro_export] -macro_rules! ifref { - (noref, $a:expr, $b:expr) => { $b }; - (ref, $a:expr, $b:expr) => { $a }; -} - +// macro_rules! ifref { +// (noref, $a:expr, $b:expr) => { +// $b +// }; +// (ref, $a:expr, $b:expr) => { +// $a +// }; +// } /// Annotate `x` with a lifetime if the first parameter /// Typically to be used from another macro. @@ -32,10 +41,14 @@ /// maybe_ref!(ref, &'a V) // ➡ &'a V /// maybe_ref!(noref, &'a V) // ➡ V /// ``` -#[macro_export] macro_rules! maybe_lifetime { - (ref, $x:ty) => { $x }; - (noref, &$lt:lifetime $x:ty) => { $x }; - (noref, &$x:ty) => { $x }; + (ref, $x:ty) => { + $x + }; + (noref, &$lt:lifetime $x:ty) => { + $x + }; + (noref, &$x:ty) => { + $x + }; } -