Skip to content

Commit 260a436

Browse files
committed
fix: enable serde default for span in symbolic expressions
1 parent 101a3bb commit 260a436

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

clarity/src/vm/representations.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -454,13 +454,17 @@ pub struct SymbolicExpression {
454454
pub id: u64,
455455

456456
#[cfg(feature = "developer-mode")]
457+
#[serde(default)]
457458
pub span: Span,
458459

459460
#[cfg(feature = "developer-mode")]
461+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
460462
pub pre_comments: Vec<(String, Span)>,
461463
#[cfg(feature = "developer-mode")]
464+
#[serde(default, skip_serializing_if = "Option::is_none")]
462465
pub end_line_comment: Option<String>,
463466
#[cfg(feature = "developer-mode")]
467+
#[serde(default, skip_serializing_if = "Vec::is_empty")]
464468
pub post_comments: Vec<(String, Span)>,
465469
}
466470

@@ -650,7 +654,7 @@ impl fmt::Display for SymbolicExpression {
650654
}
651655
}
652656

653-
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
657+
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
654658
pub struct Span {
655659
pub start_line: u32,
656660
pub start_column: u32,
@@ -666,12 +670,7 @@ impl Span {
666670
end_column: 0,
667671
};
668672

669-
pub fn zero() -> Span {
670-
Span {
671-
start_line: 0,
672-
start_column: 0,
673-
end_line: 0,
674-
end_column: 0,
675-
}
673+
pub fn zero() -> Self {
674+
Self::default()
676675
}
677676
}

0 commit comments

Comments
 (0)