From 55e6a948e3476ee300fd88e9f7ebb129c32b90c0 Mon Sep 17 00:00:00 2001 From: Ken Hoover Date: Thu, 5 Sep 2024 20:17:03 -0700 Subject: [PATCH] Revert making the inner u8 of RoomCoordinate pub. (#540) --- src/local/room_coordinate.rs | 2 +- src/local/room_xy.rs | 2 +- src/local/room_xy/extra_math.rs | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/local/room_coordinate.rs b/src/local/room_coordinate.rs index 7a151a91..936ef202 100644 --- a/src/local/room_coordinate.rs +++ b/src/local/room_coordinate.rs @@ -21,7 +21,7 @@ impl Error for OutOfBoundsError {} Debug, Hash, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, )] #[serde(try_from = "u8", into = "u8")] -pub struct RoomCoordinate(pub u8); +pub struct RoomCoordinate(u8); impl RoomCoordinate { /// Create a `RoomCoordinate` from a `u8`, returning an error if the diff --git a/src/local/room_xy.rs b/src/local/room_xy.rs index 4f1e9699..78d328fe 100644 --- a/src/local/room_xy.rs +++ b/src/local/room_xy.rs @@ -265,7 +265,7 @@ impl fmt::Display for RoomXY { impl From for (u8, u8) { fn from(xy: RoomXY) -> (u8, u8) { - (xy.x.0, xy.y.0) + (xy.x.u8(), xy.y.u8()) } } diff --git a/src/local/room_xy/extra_math.rs b/src/local/room_xy/extra_math.rs index 4f8f933e..d26c73a3 100644 --- a/src/local/room_xy/extra_math.rs +++ b/src/local/room_xy/extra_math.rs @@ -162,8 +162,8 @@ impl Sub for RoomXY { /// ``` #[inline] fn sub(self, other: RoomXY) -> (i8, i8) { - let dx = self.x.0.wrapping_sub(other.x.0) as i8; - let dy = self.y.0.wrapping_sub(other.y.0) as i8; + let dx = self.x.u8() as i8 - other.x.u8() as i8; + let dy = self.y.u8() as i8 - other.y.u8() as i8; (dx, dy) } }