You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
563 B
33 lines
563 B
//! Extensions
|
|
use super::*;
|
|
|
|
pub trait Tuple2MapExt<T>
|
|
{
|
|
fn map<F, U>(self, fun: F) -> (U, U)
|
|
where F: FnMut(T) -> U;
|
|
}
|
|
|
|
impl<T> Tuple2MapExt<T> for (T,T)
|
|
{
|
|
fn map<F, U>(self, mut fun: F) -> (U, U)
|
|
where F: FnMut(T) -> U
|
|
{
|
|
(fun(self.0), fun(self.1))
|
|
}
|
|
}
|
|
|
|
pub trait JitterExt<T>
|
|
{
|
|
/// Produce a random value between `self.0` and `self.1` inclusive
|
|
fn jitter(self) -> T;
|
|
}
|
|
|
|
impl<T> JitterExt<T> for (T, T)
|
|
where T: rand::distributions::uniform::SampleUniform
|
|
{
|
|
fn jitter(self) -> T
|
|
{
|
|
util::jitter(self.0, self.1)
|
|
}
|
|
}
|