Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub struct Basketball {
- color: Box<Color>,
- shape: Box<Shape>,
- }
- impl Basketball {
- pub fn new() -> Basketball {
- let orange = Box::new(Orange{});
- let ball = Box::new(Ball{});
- Basketball{ color: orange, shape: ball }
- }
- }
- impl Color for Basketball {
- fn color<'a>(&self) -> &'a str {
- self.color.color()
- }
- }
- impl Shape for Basketball {
- fn shape<'a>(&self) -> &'a str {
- self.shape.shape()
- }
- }
- impl Item for Basketball {
- fn name<'a>(&self) -> &'a str {
- "basketball"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement