Skip to content

Instantly share code, notes, and snippets.

@sakex
Created June 23, 2020 18:21
Show Gist options
  • Save sakex/9ed45bb0ed5600d51a16647917262100 to your computer and use it in GitHub Desktop.
Save sakex/9ed45bb0ed5600d51a16647917262100 to your computer and use it in GitHub Desktop.
// 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