Skip to content

Commit 1b2b03d

Browse files
committed
enable serde feat for spans and locations
1 parent a04888a commit 1b2b03d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/tokenizer.rs

+3
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,7 @@ impl fmt::Display for Whitespace {
417417

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

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

505507
/// A [Token] with [Location] attached to it
506508
#[derive(Debug, Eq, Hash, Clone)]
509+
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
507510
pub struct TokenWithLocation {
508511
pub token: Token,
509512
pub span: Span,

0 commit comments

Comments
 (0)