Closed
Description
This segfaults on the second call to fruit.eat()
:
trait Fruit {
fn eat(&self);
}
struct Apple {
x: int
}
impl Fruit for Apple {
fn eat(&self) {
println(fmt!("Crunching on apple %d", self.x));
}
}
fn main() {
let fruits: ~[ ~Fruit ] = ~[
~Apple{ x: 1 } as ~Fruit,
~Apple{ x: 2 } as ~Fruit,
~Apple{ x: 3 } as ~Fruit
];
for fruits.each |fruit| {
println(~"before");
fruit.eat();
println(~"after");
}
}
Results:
> rustc --version
rustc 0.6
host: x86_64-apple-darwin
> rustc test.rs
warning: no debug symbols in executable (-arch x86_64)
> ./test
before
Crunching on apple 1
after
before
Segmentation fault: 11
Metadata
Metadata
Assignees
Labels
No labels