Created
June 23, 2020 18:21
-
-
Save sakex/9ed45bb0ed5600d51a16647917262100 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// src/main.rs | |
mod button; | |
mod engine; | |
mod bindings; | |
use button::Button; | |
pub struct CounterButton { | |
count: i32 | |
} | |
impl Button for CounterButton { | |
fn click(&mut self) { | |
self.count += 1; | |
} | |
fn inner_text(&mut self) -> String { | |
format!("Count: {}", self.count) | |
} | |
} | |
fn main() { | |
let mut engine = Engine::new(); | |
let button1 = Box::new(CounterButton { count: 0 }); | |
let button2 = Box::new(CounterButton { count: 20 }); | |
engine.register_button(button1); | |
engine.register_button(button2); | |
for _ in 0..3{ | |
engine.click(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment