Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::fmt::Debug;
- trait Hittable: Debug {
- fn hit(&self);
- }
- #[derive(Debug)]
- struct Sphere ;
- impl Hittable for Sphere {
- fn hit(&self){}
- }
- #[derive(Debug)]
- struct Cube ;
- impl Hittable for Cube {
- fn hit(&self){}
- }
- fn main() {
- let mut objects: Vec<Box<Hittable>> = Vec::new();
- objects.push(Box::new(Sphere));
- objects.push(Box::new(Cube));
- println!("{:?}", &objects);
- }
Add Comment
Please, Sign In to add comment