Skip to content

Commit 7ff47a1

Browse files
authored
feat: mark some functions in bevy_math as const (#16439)
# Objective Mark simple functions as const in `bevy_math` #16124 ## Solution - Make them const ## Testing `cargo test -p bevy_math --all-features`
1 parent d82bbd8 commit 7ff47a1

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

crates/bevy_math/src/aspect_ratio.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,31 +45,31 @@ impl AspectRatio {
4545

4646
/// Returns the aspect ratio as a f32 value.
4747
#[inline]
48-
pub fn ratio(&self) -> f32 {
48+
pub const fn ratio(&self) -> f32 {
4949
self.0
5050
}
5151

5252
/// Returns the inverse of this aspect ratio (height/width).
5353
#[inline]
54-
pub fn inverse(&self) -> Self {
54+
pub const fn inverse(&self) -> Self {
5555
Self(1.0 / self.0)
5656
}
5757

5858
/// Returns true if the aspect ratio represents a landscape orientation.
5959
#[inline]
60-
pub fn is_landscape(&self) -> bool {
60+
pub const fn is_landscape(&self) -> bool {
6161
self.0 > 1.0
6262
}
6363

6464
/// Returns true if the aspect ratio represents a portrait orientation.
6565
#[inline]
66-
pub fn is_portrait(&self) -> bool {
66+
pub const fn is_portrait(&self) -> bool {
6767
self.0 < 1.0
6868
}
6969

7070
/// Returns true if the aspect ratio is exactly square.
7171
#[inline]
72-
pub fn is_square(&self) -> bool {
72+
pub const fn is_square(&self) -> bool {
7373
self.0 == 1.0
7474
}
7575
}

crates/bevy_math/src/rotation2d.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ impl Rot2 {
350350
#[inline]
351351
#[must_use]
352352
#[doc(alias = "conjugate")]
353-
pub fn inverse(self) -> Self {
353+
pub const fn inverse(self) -> Self {
354354
Self {
355355
cos: self.cos,
356356
sin: -self.sin,

0 commit comments

Comments
 (0)