daily pastebin goal
52%
SHARE
TWEET

Untitled

a guest Feb 16th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top