Skip to content

Commit

Permalink
fix: generalize from_types macro
Browse files Browse the repository at this point in the history
  • Loading branch information
nfejzic committed Nov 19, 2023
1 parent c0ce1b0 commit 82b4191
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/elements/mn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> From<T> for MathMl
where
Expand Down
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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),
Expand All @@ -30,5 +32,4 @@ macro_rules! from_types {
};
}

use elements::Num;
pub(crate) use from_types;

0 comments on commit 82b4191

Please sign in to comment.