mirror of
https://github.com/bevyengine/bevy
synced 2024-11-27 07:00:18 +00:00
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:
parent
d82bbd8370
commit
7ff47a111f
2 changed files with 6 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue