Closed
Description
The demo code from Closed01 doesn't compile.
use std::rand::{Closed01, random};
fn main() {
let Closed01(val) = random::<Closed01<f32>>();
println!("{} is a random number between 0 and 1!", val);
}
The compiler gives an error message of
error: mismatched types: expected `std::rand::Closed01<f32>` but found
`std::rand::Closed01<BUG[0u]>` (expected f32 but found type parameter)
@huonw found a workaround by wrapping it in a function:
rust fn extract<T>(Closed01(x): Closed01<T>) -> T { x }
I'm not sure what exactly is going on here, but I'm guessing it has something to do with the double generic function <Closed01> and let pattern matching for tuple structs.