1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 14:20:04 -04:00

Replace Id::null() with Id::NULL (#3544)

Shorter and more idiomatic
This commit is contained in:
Emil Ernerfeldt
2023-11-11 21:40:02 +01:00
committed by GitHub
parent b27aa27e94
commit 6ba356d3d8
6 changed files with 17 additions and 20 deletions

View File

@@ -55,21 +55,15 @@ pub use {
/// Helper trait to implement [`lerp`] and [`remap`].
pub trait One {
fn one() -> Self;
const ONE: Self;
}
impl One for f32 {
#[inline(always)]
fn one() -> Self {
1.0
}
const ONE: Self = 1.0;
}
impl One for f64 {
#[inline(always)]
fn one() -> Self {
1.0
}
const ONE: Self = 1.0;
}
/// Helper trait to implement [`lerp`] and [`remap`].
@@ -107,7 +101,7 @@ where
R: Copy + Add<R, Output = R>,
{
let range = range.into();
(T::one() - t) * *range.start() + t * *range.end()
(T::ONE - t) * *range.start() + t * *range.end()
}
/// Where in the range is this value? Returns 0-1 if within the range.
@@ -174,7 +168,7 @@ where
crate::emath_assert!(from.start() != from.end());
let t = (x - *from.start()) / (*from.end() - *from.start());
// Ensure no numerical inaccuracies sneak in:
if T::one() <= t {
if T::ONE <= t {
*to.end()
} else {
lerp(to, t)