From 36eedbfa92023fad94fd218de195196f642935a4 Mon Sep 17 00:00:00 2001 From: Emi <95967983+EmiOnGit@users.noreply.github.com> Date: Wed, 30 Aug 2023 19:31:30 +0200 Subject: [PATCH] Change `Urect::width` & `Urect::height` to be const (#9640) # Objective The two functions [`Urect::height`](https://docs.rs/bevy_math/latest/bevy_math/struct.URect.html#method.height), [`Urect::width`](https://docs.rs/bevy_math/latest/bevy_math/struct.URect.html#method.width) are currently not const. Since the methods are very unlikely to change (ever) and are useful to be const for some games, they should be. Co-authored-by: Emi --- crates/bevy_math/src/rects/urect.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/bevy_math/src/rects/urect.rs b/crates/bevy_math/src/rects/urect.rs index fb74a6183e..73517de305 100644 --- a/crates/bevy_math/src/rects/urect.rs +++ b/crates/bevy_math/src/rects/urect.rs @@ -130,7 +130,7 @@ impl URect { /// assert_eq!(r.width(), 5); /// ``` #[inline] - pub fn width(&self) -> u32 { + pub const fn width(&self) -> u32 { self.max.x - self.min.x } @@ -144,7 +144,7 @@ impl URect { /// assert_eq!(r.height(), 1); /// ``` #[inline] - pub fn height(&self) -> u32 { + pub const fn height(&self) -> u32 { self.max.y - self.min.y }