From 34f5376517d171ab88323c762540a010bbdb54cc Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Mon, 24 Jun 2024 16:55:56 -0700 Subject: [PATCH] [naga] Clarify `Debug` form of `arena::Range`. Change the `std::fmt::Debug` impl for `naga::arena::Range` to print a start-inclusive, end-exclusive range. - This is more consistent with Rust's `std::ops::Range`. - This is consistent with the serialization form used in snapshots, which simply uses the serialization of `std::ops::Range`. - It is not consistent with Naga's constructor function `Range::new_from_bounds`, which takes an inclusive end value, or with `Range::first_and_last`, which returns an inclusive end value. Both of these need to represent ranges' end points as `Handle`s, but exclusive end values might not be valid `Handle` values. I think this divergence is tolerable. --- naga/src/arena/range.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/naga/src/arena/range.rs b/naga/src/arena/range.rs index 80b8c101b4..74e042abe2 100644 --- a/naga/src/arena/range.rs +++ b/naga/src/arena/range.rs @@ -68,7 +68,7 @@ impl Clone for Range { impl fmt::Debug for Range { fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result { - write!(formatter, "[{}..{}]", self.inner.start, self.inner.end - 1) + write!(formatter, "[{}..{}]", self.inner.start, self.inner.end) } }