trait 对象必须写 dyn

版本新特性 / Rust 2018

// *** before: ***
// a bare trait name in type position meant a trait object,
// and it was indistinguishable from the trait itself
fn draw_all(shapes: &[Box<Shape>]) {
    for s in shapes {
        s.draw();
    }
}

// *** in version Rust 2018: ***
// a trait object is marked dyn: the call clearly goes through a table
fn draw_all(shapes: &[Box<dyn Shape>]) {
    for s in shapes {
        s.draw();
    }
}