From dc002023cd948038dee94de8f8cc5e2a96057afb Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 2 Dec 2024 03:50:51 -0500 Subject: [PATCH] Clean up token.rs --- dust-lang/src/token.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/dust-lang/src/token.rs b/dust-lang/src/token.rs index 385effc..0bf75e5 100644 --- a/dust-lang/src/token.rs +++ b/dust-lang/src/token.rs @@ -28,25 +28,22 @@ pub fn write_token_list(tokens: &[(Token, Span)], styled: bool, writer } macro_rules! define_tokens { - ($($variant:ident $(($data_type:ty))?),+ $(,)?) => { + ($($variant:ident $(($data_type:ty))?),+) => { /// Source token. /// /// This is a borrowed type, i.e. some variants contain references to the source text. - #[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Default, Serialize, Deserialize)] + #[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)] pub enum Token<'src> { - #[default] - Eof, $( $variant $(($data_type))?, )* } - #[derive(Debug, PartialEq, Clone)] + #[derive(Debug, Clone, Copy, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)] /// Data-less representation of a source token. /// /// If a [Token] borrows from the source text, its TokenKind omits the data. pub enum TokenKind { - Eof, $( $variant, )* @@ -55,6 +52,8 @@ macro_rules! define_tokens { } define_tokens! { + Eof, + // Hard-coded values Boolean(&'src str), Byte(&'src str), @@ -114,7 +113,7 @@ define_tokens! { Slash, SlashEqual, Star, - StarEqual, + StarEqual } impl<'src> Token<'src> { @@ -472,7 +471,7 @@ impl<'src> Display for Token<'src> { /// Owned representation of a source token. /// /// If a [Token] borrows from the source text, its TokenOwned omits the data. -#[derive(Debug, PartialEq, Clone)] +#[derive(Debug, Clone, Eq, PartialEq, PartialOrd, Ord, Serialize, Deserialize)] pub enum TokenOwned { Eof,