Skip to content

Commit 0f6ec6f

Browse files
committed
syntax: improve Debug impl for IntervalSet
This shows up in the Debug representation of an HIR. This impl removes a layer of indirection in the output and drops internal optimization fields like 'folded'.
1 parent b85f15f commit 0f6ec6f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

regex-syntax/src/hir/interval.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::unicode;
3030
//
3131
// Tests on this are relegated to the public API of HIR in src/hir.rs.
3232

33-
#[derive(Clone, Debug)]
33+
#[derive(Clone)]
3434
pub struct IntervalSet<I> {
3535
/// A sorted set of non-overlapping ranges.
3636
ranges: Vec<I>,
@@ -64,6 +64,16 @@ impl<I: Interval> PartialEq for IntervalSet<I> {
6464
}
6565
}
6666

67+
impl<I: core::fmt::Debug> core::fmt::Debug for IntervalSet<I> {
68+
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
69+
let mut fmter = f.debug_tuple("IntervalSet");
70+
for range in self.ranges.iter() {
71+
fmter.field(range);
72+
}
73+
fmter.finish()
74+
}
75+
}
76+
6777
impl<I: Interval> IntervalSet<I> {
6878
/// Create a new set from a sequence of intervals. Each interval is
6979
/// specified as a pair of bounds, where both bounds are inclusive.

0 commit comments

Comments
 (0)