Skip to content

Instantly share code, notes, and snippets.

@nightpool
Created January 13, 2014 03:02
Show Gist options
  • Save nightpool/8394056 to your computer and use it in GitHub Desktop.
Save nightpool/8394056 to your computer and use it in GitHub Desktop.
fn random_num<T: num::NumCast + num::Num>(n: T) -> T {
let rand::Closed01(val) = random::<rand::Closed01<f32>>();
num::cast(val * num::cast(n).unwrap()).unwrap()
}
@nightpool
Copy link
Author

test-sdl.rs:21:9: 21:28 error: mismatched types: expected `std::rand::Closed01<f32>` but found `std::rand::Closed01<BUG[0u]>` (expected f32 but found type parameter)
test-sdl.rs:21     let rand::Closed01(val) = random::<rand::Closed01<f32>>();
                       ^~~~~~~~~~~~~~~~~~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment