From 7e8ee5ed9cad6484e9f13f81731b102ced58402e Mon Sep 17 00:00:00 2001 From: Adam Carpenter Date: Tue, 9 Jul 2019 15:14:04 -0400 Subject: Init. --- rust-book/oop/src/lib.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100755 rust-book/oop/src/lib.rs (limited to 'rust-book/oop/src/lib.rs') diff --git a/rust-book/oop/src/lib.rs b/rust-book/oop/src/lib.rs new file mode 100755 index 0000000..91ef2e8 --- /dev/null +++ b/rust-book/oop/src/lib.rs @@ -0,0 +1,41 @@ +pub trait Draw { + fn draw(&self); +} + +pub struct Screen { + pub components: Vec>, +} + +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) { + dbg!("drew button"); + } +} + +pub struct SelectBox { + pub width: u32, + pub height: u32, + pub options: Vec, +} + +impl Draw for SelectBox { + fn draw(&self) { + dbg!("drew select box"); + } +} + + -- cgit v1.2.3