From c7402b8dabd45f62e814e7a97cf3fbf9791d8cf7 Mon Sep 17 00:00:00 2001 From: John Breaux Date: Mon, 5 Aug 2024 12:38:17 -0500 Subject: [PATCH] msp430-asm: use macro_rules! instead of nightly `macro` syntax. It may be nice, but y'know what's nicer? Building on stable. --- msp430-asm/src/lib.rs | 42 +++++++++++++++++++++++++++++++----------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/msp430-asm/src/lib.rs b/msp430-asm/src/lib.rs index 33b77d4..9c15580 100644 --- a/msp430-asm/src/lib.rs +++ b/msp430-asm/src/lib.rs @@ -1,5 +1,4 @@ //! Helper library for msp430-asm -#![feature(decl_macro)] pub mod split_twice { /// Slices a collection into a beginning, middle, and end, based on two unordered indices pub trait SplitTwice<'t> { @@ -63,30 +62,51 @@ pub mod cursor { use std::fmt::{Arguments, Display}; /// Moves to the {line}th previous line - pub macro previous($line:literal) { - csi!("{}F", $line) + #[macro_export] + macro_rules! previous { + ($line:literal) => { + csi!("{}F", $line) + }; } /// Injects a Command Sequence Introducer - pub macro csi($($t:tt)*) { - format_args!("\x1b[{}", format_args!($($t)*)) + #[macro_export] + macro_rules! csi { + ($($t:tt)*) => { + format_args!("\x1b[{}", format_args!($($t)*)) + }; } /// Formats the args with a foreground [Color] - pub macro fg($fg:expr, $($t:tt)*) { - Colorized::new(Some($fg), None, format_args!($($t)*)) + #[macro_export] + macro_rules! fg { + ($fg:expr, $($t:tt)*) => { + Colorized::new(Some($fg), None, format_args!($($t)*)) + }; } /// Formats the args with a background [Color] - pub macro bg($bg:expr, $(t:tt)*) { - Colorized::new(None, Some($bg), format_args!($($t)*)) + #[macro_export] + macro_rules! bg { + ($bg:expr, $(t:tt)*) => { + Colorized::new(None, Some($bg), format_args!($($t)*)) + }; } /// Formats the args with both a foreground and background [Color] - pub macro color($fg:expr, $bg:expr, $($t:tt)*) { - Colorized::new(Some($fg), Some($bg), format_args!($($t)*)) + #[macro_export] + macro_rules! color { + ($fg:expr, $bg:expr, $($t:tt)*) => { + Colorized::new(Some($fg), Some($bg), format_args!($($t)*)) + } } + pub use bg; + pub use color; + pub use csi; + pub use fg; + pub use previous; + #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] pub enum Color { #[default]