2016-04-26 10:51:14 -07:00
|
|
|
pub struct Closed01<F>(pub F);
|
|
|
|
|
|
|
|
pub trait Bar { fn new() -> Self; }
|
|
|
|
|
|
|
|
impl<T: Bar> Bar for Closed01<T> {
|
|
|
|
fn new() -> Closed01<T> { Closed01(Bar::new()) }
|
2015-03-18 22:05:24 +01:00
|
|
|
}
|
2016-04-26 10:51:14 -07:00
|
|
|
impl Bar for f32 { fn new() -> f32 { 1.0 } }
|
|
|
|
|
|
|
|
pub fn random<T: Bar>() -> T { Bar::new() }
|