chaosgui/lib.rs
1//! #Chaos's first Crate
2//!
3//! Chaos's first Crate is a cllection of utilities to test polymorphism
4//!
5//! See each components how to use Draw Trait in Screen
6//!
7
8#[cfg(test)]
9mod tests {
10 #[test]
11 fn it_works() {
12 assert_eq!(2 + 2, 4);
13 }
14}
15
16/// # Examples
17///
18/// impl Draw for SelectBox {
19///
20/// fn draw(&self) {
21///
22/// println!("draw SelectBox");
23///
24/// }
25///
26/// }
27///
28///
29pub trait Draw {
30 fn draw(&self);
31}
32
33pub struct Screen {
34 pub components: Vec<Box<Draw>>,
35}
36
37impl Screen {
38 pub fn run(&self) {
39 for component in self.components.iter() {
40 component.draw();
41 }
42 }
43}
44
45pub struct Button {
46 pub width: u32,
47 pub height: u32,
48 pub label: String,
49}
50
51impl Draw for Button {
52 fn draw(&self) {
53 println!("draw button");
54 }
55}