Something went wrong on our end
utilities.rs 809 B
#[inline]
pub fn f32_max(a: f32, b: f32) -> f32 {
if a > b {
a
} else {
b
}
}
#[inline]
pub fn f32_max_mag(a: f32, b: f32) -> f32 {
if a.abs() > b.abs() {
a.abs()
} else {
b.abs()
}
}
#[inline]
pub fn f32_min(a: f32, b: f32) -> f32 {
if a < b {
a
} else {
b
}
}
#[inline]
pub fn f32_min_mag(a: f32, b: f32) -> f32 {
if a.abs() < b.abs() {
a.abs()
} else {
b.abs()
}
}
#[macro_export]
macro_rules! deref_as {
($name: ident => $target: ty) => {
impl std::ops::Deref for $name {
type Target = $target;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl std::ops::DerefMut for $name {
fn deref_mut(&mut self) -> &mut Self::Target {
&mut self.0
}
}
impl From<$target> for $name {
fn from(other: $target) -> $name {
$name(other)
}
}
};
}