Skip to content

Commit

Permalink
Change Urect::width & Urect::height to be const (#9640)
Browse files Browse the repository at this point in the history
# 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 <emanuel.boehm@gmail.com>
  • Loading branch information
EmiOnGit and Emi authored Aug 30, 2023
1 parent 42e6dc8 commit 36eedbf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions crates/bevy_math/src/rects/urect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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
}

Expand Down

0 comments on commit 36eedbf

Please sign in to comment.