These are chat archives for rust-lang/rust

8th
Feb 2017
Nate
@phaux
Feb 08 2017 13:21
Question: Why are there traits like IntoIterator when there's also Into which could be used as Into<Iterator>. Does it have something to do with lack of higher kinded types?
Denis Lisov
@tanriol
Feb 08 2017 13:27
Because Into<Iterator> cannot really be used this way :-)
Denis Lisov
@tanriol
Feb 08 2017 13:32
IntoIterator encodes which type implementing Iterator is to be used. With Into you'd have to specify it manually.
Nate
@phaux
Feb 08 2017 13:37
I see
mhsjlw
@mhsjlw
Feb 08 2017 13:48
How can I generate a random number from 0 (inclusive) to x? I'm using the rand crate, but it doesn
*'t seem to have anything like that?
Sergey Noskov
@Albibek
Feb 08 2017 13:50
usual practice is to generate a random integer r and then do r modulo x
Denis Lisov
@tanriol
Feb 08 2017 13:51
See rand::distributions::Range (doc)
mhsjlw
@mhsjlw
Feb 08 2017 14:12
I'll take a look, thanks
Eric (Photon)
@Pheric
Feb 08 2017 23:47
I've used java for about a year and have been hearing a lot abut Rust. Why should I learn it? (sales pitch)