chaosgui 0.1.0

test for trait
Documentation
//! #Chaos's first Crate
//!
//! Chaos's first Crate is a cllection of utilities to test polymorphism
//!
//! See each components how to use Draw Trait in Screen
//!

#[cfg(test)]
mod tests {
    #[test]
    fn it_works() {
        assert_eq!(2 + 2, 4);
    }
}

/// # Examples
///
///   impl Draw for SelectBox {
///
///     fn draw(&self) {
///
///         println!("draw SelectBox");
///
///     }
///
///   }
///
///
pub trait Draw {
    fn draw(&self);
}

pub struct Screen {
    pub components: Vec<Box<Draw>>,
}

impl Screen {
    pub fn run(&self) {
        for component in self.components.iter() {
            component.draw();
        }
    }
}

pub struct Button {
    pub width: u32,
    pub height: u32,
    pub label: String,
}

impl Draw for Button {
    fn draw(&self) {
        println!("draw button");
    }
}