Guest User

Untitled

a guest
Feb 18th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. pub trait Widget<'a> {
  2. fn addChild(&mut self, child: &'a Widget<'a>);
  3. }
  4.  
  5. pub struct WidgetImpl<'a> {
  6. pub children: Vec<&'a Widget<'a>>
  7. }
  8.  
  9. impl<'a> WidgetImpl<'a> {
  10. pub fn new() -> Self {
  11. let children: Vec<&'a Widget<'a>> = Vec::new();
  12. WidgetImpl {
  13. children
  14. }
  15. }
  16. }
  17.  
  18. impl<'a> Widget<'a> for WidgetImpl<'a> {
  19. fn addChild(&mut self, child: &'a Widget<'a>) {
  20. self.children.push(child);
  21. }
  22.  
  23. }
  24.  
  25.  
  26.  
  27. fn main() {
  28. println!("Hello, world!");
  29. }
Add Comment
Please, Sign In to add comment