Watch
1
0
Fork
You've already forked souveraine
0

atmosphere: say the NaN case out loud

!(t > 0.0) trips clippy's partial-ord lint under the pinned 1.94 toolchain,
which blocks the whole gate. t.is_nan() || t <= 0.0 is the same predicate
written so the NaN intent is legible, with a test pinning both ends.
This commit is contained in:
Fimeg 2026-08-17 08:42:19 -04:00
commit b3bbfeeac4

View file

@ -224,7 +224,7 @@ impl Atmosphere {
/// extrapolated colour: a transition is a journey between two rooms she /// extrapolated colour: a transition is a journey between two rooms she
/// chose, and there is nothing past either end of it. /// chose, and there is nothing past either end of it.
pub fn lerp(self, other: Atmosphere, t: f32) -> Atmosphere { pub fn lerp(self, other: Atmosphere, t: f32) -> Atmosphere {
if self == other || !(t > 0.0) { if self == other || t.is_nan() || t <= 0.0 {
return self; return self;
} }
if t >= 1.0 { if t >= 1.0 {
@ -243,6 +243,19 @@ impl Atmosphere {
mod tests { mod tests {
use super::*; use super::*;
#[test]
fn a_blend_outside_the_journey_resolves_to_an_endpoint() {
// `!(t > 0.0)` said this and tripped clippy's partial-ord lint, which
// blocks the CI gate. NaN and every t <= 0 must still land on `self`.
let a = Atmosphere::MintTea;
let b = Atmosphere::NeonGlow;
assert_eq!(a.lerp(b, f32::NAN), a, "NaN is not a place on the journey");
assert_eq!(a.lerp(b, 0.0), a);
assert_eq!(a.lerp(b, -1.0), a);
assert_eq!(a.lerp(b, 1.0), b);
assert_eq!(a.lerp(b, 2.0), b);
}
#[test] #[test]
fn a_blend_is_a_value_between_the_two_rooms() { fn a_blend_is_a_value_between_the_two_rooms() {
let mid = Atmosphere::MintTea.lerp(Atmosphere::NeonGlow, 0.5); let mid = Atmosphere::MintTea.lerp(Atmosphere::NeonGlow, 0.5);