support latest macro syntax

master
Sameer Puri 5 years ago
parent 24318598bd
commit b74291c6b0

@ -48,7 +48,7 @@ macro_rules! command {
} }
macro_rules! commands { macro_rules! commands {
($($(#[$outer:meta])* $commandName: ident {$letter: pat, $number: pat, $fraction: pat, {$($(#[$inner:meta])* $argument: ident), *} },)*) => { ($($(#[$outer:meta])* $commandName: ident {$letter: expr, $number: expr, $fraction: path, {$($(#[$inner:meta])* $argument: ident), *} },)*) => {
/// Commands are the operational unit of GCode /// Commands are the operational unit of GCode
/// They consist of an identifying word followed by arguments /// They consist of an identifying word followed by arguments
@ -58,7 +58,6 @@ macro_rules! commands {
arguments: Vec<Word> arguments: Vec<Word>
} }
paste::item! {
impl Command { impl Command {
pub fn new(command_word: CommandWord, mut arguments: Vec<Word>) -> Self { pub fn new(command_word: CommandWord, mut arguments: Vec<Word>) -> Self {
Self { Self {
@ -87,9 +86,7 @@ macro_rules! commands {
} }
} }
} }
}
paste::item! {
impl Into<Vec<Word>> for Command { impl Into<Vec<Word>> for Command {
fn into(self) -> Vec<Word> { fn into(self) -> Vec<Word> {
let mut args = self.arguments; let mut args = self.arguments;
@ -97,9 +94,7 @@ macro_rules! commands {
args args
} }
} }
}
paste::item! {
impl TryFrom<&[Word]> for Command { impl TryFrom<&[Word]> for Command {
type Error = (); type Error = ();
fn try_from(words: &[Word]) -> Result<Self, ()> { fn try_from(words: &[Word]) -> Result<Self, ()> {
@ -125,7 +120,6 @@ macro_rules! commands {
}) })
} }
} }
}
#[derive(Clone, PartialEq, Eq)] #[derive(Clone, PartialEq, Eq)]
pub enum CommandWord { pub enum CommandWord {
@ -141,7 +135,6 @@ macro_rules! commands {
Checksum(u8), Checksum(u8),
} }
paste::item! {
impl CommandWord { impl CommandWord {
pub fn is_command(word: &Word) -> bool { pub fn is_command(word: &Word) -> bool {
let (number, fraction) = match &word.value { let (number, fraction) = match &word.value {
@ -156,8 +149,7 @@ macro_rules! commands {
} }
} }
} }
}
paste::item! {
impl TryFrom<&Word> for CommandWord { impl TryFrom<&Word> for CommandWord {
type Error = (); type Error = ();
fn try_from(word: &Word) -> Result<Self, ()> { fn try_from(word: &Word) -> Result<Self, ()> {
@ -173,8 +165,7 @@ macro_rules! commands {
} }
} }
} }
}
paste::item!{
impl Into<Word> for CommandWord { impl Into<Word> for CommandWord {
fn into(self) -> Word { fn into(self) -> Word {
match self { match self {
@ -200,7 +191,6 @@ macro_rules! commands {
} }
} }
} }
}
}; };
} }

Loading…
Cancel
Save