feat: mark some functions in bevy_math as const (#16439)

# Objective

Mark simple functions as const in `bevy_math`
https://github.com/bevyengine/bevy/issues/16124

## Solution

- Make them const

## Testing

`cargo test -p bevy_math --all-features`
This commit is contained in:
DAA 2024-11-22 19:26:47 +01:00 committed by GitHub
parent d82bbd8370
commit 7ff47a111f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -45,31 +45,31 @@ impl AspectRatio {
/// Returns the aspect ratio as a f32 value.
#[inline]
pub fn ratio(&self) -> f32 {
pub const fn ratio(&self) -> f32 {
self.0
}
/// Returns the inverse of this aspect ratio (height/width).
#[inline]
pub fn inverse(&self) -> Self {
pub const fn inverse(&self) -> Self {
Self(1.0 / self.0)
}
/// Returns true if the aspect ratio represents a landscape orientation.
#[inline]
pub fn is_landscape(&self) -> bool {
pub const fn is_landscape(&self) -> bool {
self.0 > 1.0
}
/// Returns true if the aspect ratio represents a portrait orientation.
#[inline]
pub fn is_portrait(&self) -> bool {
pub const fn is_portrait(&self) -> bool {
self.0 < 1.0
}
/// Returns true if the aspect ratio is exactly square.
#[inline]
pub fn is_square(&self) -> bool {
pub const fn is_square(&self) -> bool {
self.0 == 1.0
}
}

View file

@ -350,7 +350,7 @@ impl Rot2 {
#[inline]
#[must_use]
#[doc(alias = "conjugate")]
pub fn inverse(self) -> Self {
pub const fn inverse(self) -> Self {
Self {
cos: self.cos,
sin: -self.sin,