Skip to content

Commit fab42ce

Browse files
Expose EgglogSpan publicly and add debug to spans
This PR makes public the fields on the egglog span so that we can access them from the Python bindings. In Python, I have been generally converting to/from egglog sructs by creating a corresponding Python class and copying all of their fields. To do so , it has to be public. I also use the debug formatting to allow pretty printing in Python as the rust struct. See egraphs-good/egglog-python#258 for the corresponding PR on the Python side.
1 parent 161a36f commit fab42ce

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/ast/parse.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ pub enum Span {
1616
Rust(Arc<RustSpan>),
1717
}
1818

19-
#[derive(Clone, PartialEq, Eq, Hash)]
19+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2020
pub struct EgglogSpan {
21-
file: Arc<SrcFile>,
22-
i: usize,
23-
j: usize,
21+
pub file: Arc<SrcFile>,
22+
pub i: usize,
23+
pub j: usize,
2424
}
2525

26-
#[derive(Clone, PartialEq, Eq, Hash)]
26+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
2727
pub struct RustSpan {
2828
pub file: &'static str,
2929
pub line: u32,
@@ -51,10 +51,10 @@ impl Span {
5151
}
5252
}
5353

54-
#[derive(Debug, PartialEq, Eq, Hash)]
54+
#[derive(Debug, PartialEq, Eq, Hash, Clone)]
5555
pub struct SrcFile {
56-
name: Option<String>,
57-
contents: String,
56+
pub name: Option<String>,
57+
pub contents: String,
5858
}
5959

6060
struct Location {

0 commit comments

Comments
 (0)