Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pub trait Widget<'a> {
- fn addChild(&mut self, child: &'a Widget<'a>);
- }
- pub struct WidgetImpl<'a> {
- pub children: Vec<&'a Widget<'a>>
- }
- impl<'a> WidgetImpl<'a> {
- pub fn new() -> Self {
- let children: Vec<&'a Widget<'a>> = Vec::new();
- WidgetImpl {
- children
- }
- }
- }
- impl<'a> Widget<'a> for WidgetImpl<'a> {
- fn addChild(&mut self, child: &'a Widget<'a>) {
- self.children.push(child);
- }
- }
- fn main() {
- println!("Hello, world!");
- }
Add Comment
Please, Sign In to add comment