pub trait LerpIter {
// Required method
fn lerp_iter(self, other: Self, steps: usize) -> LerpIterator<Self> ⓘ
where Self: Sized;
// Provided method
fn lerp_iter_closed(
self,
other: Self,
steps: usize,
) -> Skip<Chain<LerpIterator<Self>, Once<Self>>> ⓘ
where Self: Copy,
LerpIterator<Self>: Iterator<Item = Self> { ... }
}Expand description
Types which can construct a lerping iterator from one point to another over a set number of steps.
This is automatically implemented for all T: Lerp<f64> + Sized.
Required Methods§
Sourcefn lerp_iter(self, other: Self, steps: usize) -> LerpIterator<Self> ⓘwhere
Self: Sized,
fn lerp_iter(self, other: Self, steps: usize) -> LerpIterator<Self> ⓘwhere
Self: Sized,
Create an iterator which lerps from self to other.
The iterator is half-open: it includes self, but not other
§Example
use lerp::LerpIter;
// lerp between 3 and 5, collecting two items
let items: Vec<_> = 3.0_f64.lerp_iter(5.0, 4).collect();
assert_eq!(vec![3.0, 3.5, 4.0, 4.5], items);Provided Methods§
Sourcefn lerp_iter_closed(
self,
other: Self,
steps: usize,
) -> Skip<Chain<LerpIterator<Self>, Once<Self>>> ⓘ
fn lerp_iter_closed( self, other: Self, steps: usize, ) -> Skip<Chain<LerpIterator<Self>, Once<Self>>> ⓘ
Create an iterator which lerps from self to other.
The iterator is closed: it returns both self and other.
Note when steps == 1, other is returned instead of self.
§Example
use lerp::LerpIter;
assert_eq!(vec![3.0, 5.0], 3.0_f64.lerp_iter_closed(5.0, 2).collect::<Vec<f64>>());Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".