rust-random / rand

A Rust library for random number generation.
https://crates.io/crates/rand
Other
1.66k stars 432 forks source link

rand::distributions::Distribution::sample using &mut #908

Closed burdges closed 4 years ago

burdges commented 4 years ago

I suppose rand::distributions::Distribution::sample takes a &mut R instead of an R because otherwise the errors get confusing?

dhardy commented 4 years ago

See this post.

burdges commented 4 years ago

Thanks! I suppose monomorphization creates another issue if you wind up with separate entry points for each &mut &mut .. &mut R.

I've no idea if Rust can optimize those away, but if not then maybe idiomatic usage should really by BorrowMut<R> whenever you might want both R and &mut R.