Advertisement
cwchen

[Rust] Using Drive trait

Aug 28th, 2017
3,341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 0.21 KB | None | 0 0
  1. fn main() {
  2.     let mut cars = Vec::new() as Vec<Box<Drive>>;
  3.     cars.push(Box::new(Toyota));
  4.     cars.push(Box::new(Honda));
  5.     cars.push(Box::new(Ford));
  6.     for c in &cars {
  7.         c.drive();
  8.     }
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement