Skip to content

Instantly share code, notes, and snippets.

@dymk
Created April 24, 2013 00:23
Show Gist options
  • Select an option

  • Save dymk/5448608 to your computer and use it in GitHub Desktop.

Select an option

Save dymk/5448608 to your computer and use it in GitHub Desktop.
struct Circle { radius: int }
trait Shape {}
impl Shape for Circle {}
fn main() {
//Doesn't crash if 'all' is immutable:
// let all: ~[~Shape] = ~[~Circle{radius: 2} as ~Shape];
//Doesn't crash if 'all' is mutable:
// let mut all: ~[~Shape] = ~[~Circle{radius: 2} as ~Shape];
//Does crash if 'all' is mutable, and is pushed to
let mut all: ~[~Shape] = ~[];
all.push(~Circle{radius: 2} as ~Shape);
//makes it here, then crashes when returning from main
io::println("kaboom!");
}
// > 'kaboom!'
// > fatal crash on Windows 7 x64
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment