// *** 以前 ***
// 类型位置上的裸 trait 名称过去表示 trait 对象,
// 与 trait 本身无法区分
fn draw_all(shapes: &[Box<Shape>]) {
for s in shapes {
s.draw();
}
}
// *** 在 Rust 2018 版本中 ***
// trait 对象用 dyn 标记:一眼就能看出调用要经过虚表
fn draw_all(shapes: &[Box<dyn Shape>]) {
for s in shapes {
s.draw();
}
}