On 17 Sep 2014, at 23:33, Sean McArthur smcart...@mozilla.com wrote:
On Wed, Sep 17, 2014 at 2:26 PM, Evan Davis cptr...@gmail.com wrote:
The problem is that you're trying to use a trait as a type.
That shouldn't be a problem. You can use a `mut Trait`, and you'll get
dynamic dispatch.
The problem is that you're trying to use a trait as a type. This code works
for me
```
use std::rand::{Rng, task_rng};
fn main() {
let rng = mut task_rng();
print_numbers(rng);
}
fn print_numbersT:Rng(r: mut T) {
for _ in range(0u, 10) {
println!({}, r.gen::uint());
}
}
On Wed, Sep 17, 2014 at 2:26 PM, Evan Davis cptr...@gmail.com wrote:
The problem is that you're trying to use a trait as a type.
That shouldn't be a problem. You can use a `mut Trait`, and you'll get
dynamic dispatch.
___
Rust-dev mailing list
Hello list,
I've got this small program:
use std::rand::{Rng, task_rng};
fn main() {
let rng = mut task_rng();
print_numbers(rng);
}
fn print_numbers(r: mut Rng) {
for _ in range(0u, 10) {
println!({}, r.gen::uint());
}
}
generating me this compiler error:
rustc
Is it to allow the following pattern?
fn print_numbersR: Rng (r: mut R) {
for _ in range(0u, 10) {
println!({}, r.gen::uint());
}
}
Pete.
___
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev