1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
/// An extension trait for `f32`.
pub trait F32Ext {
    /// Linearly interpolate between `self` and `other` with parameter `t`.
    fn lerp(self, other: f32, t: f32) -> f32;
}

impl F32Ext for f32 {
    fn lerp(self, other: f32, t: f32) -> f32 {
        self * (1.0 - t) + other * t
    }
}