From 82b419143a35f8c3d1fba072fc00903475b74b6f Mon Sep 17 00:00:00 2001 From: Nadir Fejzic Date: Sun, 19 Nov 2023 16:26:29 +0100 Subject: [PATCH] fix: generalize `from_types` macro --- src/elements/mn.rs | 2 +- src/lib.rs | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/elements/mn.rs b/src/elements/mn.rs index e90f0fa..419f950 100644 --- a/src/elements/mn.rs +++ b/src/elements/mn.rs @@ -18,7 +18,7 @@ impl<'a> From<&'a str> for Num { } } -crate::from_types!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize); +crate::from_types!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize => Num); impl From for MathMl where diff --git a/src/lib.rs b/src/lib.rs index d38d64c..002191e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,6 +4,8 @@ pub mod attributes; pub mod elements; pub mod markers; +use elements::Num; + #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)] pub(crate) enum Tag { Num(Num), @@ -16,9 +18,9 @@ pub struct MathMl { } macro_rules! from_types { - ($($type:ty),* $(,)?) => { + ($($type:path),* $(,)? => $for_type:path) => { $( - impl From<$type> for Num { + impl From<$type> for $for_type { fn from(value: $type) -> Self { Self { num: format!("{}", value), @@ -30,5 +32,4 @@ macro_rules! from_types { }; } -use elements::Num; pub(crate) use from_types;