Skip to content

Instantly share code, notes, and snippets.

@sakex
Created June 23, 2020 18:20
Show Gist options
  • Save sakex/65b8f4e93d4e99d2937419020f0d7405 to your computer and use it in GitHub Desktop.
Save sakex/65b8f4e93d4e99d2937419020f0d7405 to your computer and use it in GitHub Desktop.
pub trait Button {
fn click(&mut self);
fn inner_text(&mut self) -> String;
}
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)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment