Skip to content

Commit

Permalink
enable serde feat for spans and locations
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyrox committed Sep 30, 2024
1 parent a04888a commit 1b2b03d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/tokenizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,7 @@ impl fmt::Display for Whitespace {

/// Location in input string
#[derive(Eq, PartialEq, Hash, Clone, Copy, Ord, PartialOrd)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Location {
/// Line number, starting from 1
pub line: u64,
Expand Down Expand Up @@ -456,6 +457,7 @@ impl From<(u64, u64)> for Location {
}

#[derive(Eq, PartialEq, Hash, Clone, PartialOrd, Ord, Copy)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Span {
pub start: Location,
pub end: Location,
Expand Down Expand Up @@ -504,6 +506,7 @@ impl Span {

/// A [Token] with [Location] attached to it
#[derive(Debug, Eq, Hash, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct TokenWithLocation {
pub token: Token,
pub span: Span,
Expand Down

0 comments on commit 1b2b03d

Please sign in to comment.