Skip to content

Commit

Permalink
Better debug for SourceRef (powdr-labs#1418)
Browse files Browse the repository at this point in the history
  • Loading branch information
chriseth authored Jun 4, 2024
1 parent 33695d5 commit c5e9b06
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions parser-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
#![deny(clippy::print_stdout)]

use std::sync::Arc;
use std::{
fmt::{self, Debug, Formatter},
sync::Arc,
};

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

#[derive(
Debug, Clone, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, JsonSchema,
)]
#[derive(Clone, Default, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, JsonSchema)]
pub struct SourceRef {
pub file_name: Option<Arc<str>>,
pub file_contents: Option<Arc<str>>,
Expand All @@ -31,6 +32,18 @@ impl SourceRef {
}
}

impl Debug for SourceRef {
fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
write!(
f,
"{}:{}-{}",
self.file_name.as_deref().unwrap_or(""),
self.start,
self.end
)
}
}

#[derive(Debug)]
pub struct Error {
source_ref: SourceRef,
Expand Down

0 comments on commit c5e9b06

Please sign in to comment.