Guest User

Untitled

a guest
Feb 16th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. use std::fmt::Debug;
  2.  
  3. trait Hittable: Debug {
  4. fn hit(&self);
  5. }
  6.  
  7. #[derive(Debug)]
  8. struct Sphere ;
  9.  
  10. impl Hittable for Sphere {
  11. fn hit(&self){}
  12. }
  13.  
  14. #[derive(Debug)]
  15. struct Cube ;
  16.  
  17. impl Hittable for Cube {
  18. fn hit(&self){}
  19. }
  20.  
  21. fn main() {
  22. let mut objects: Vec<Box<Hittable>> = Vec::new();
  23. objects.push(Box::new(Sphere));
  24. objects.push(Box::new(Cube));
  25. println!("{:?}", &objects);
  26. }
Add Comment
Please, Sign In to add comment