Skip to content

Instantly share code, notes, and snippets.

@kingxsp
Forked from ALSchwalm/dispatch_1.rs
Created July 20, 2019 07:28
Show Gist options
  • Save kingxsp/e66ae9723c3abbc79434f8f89a370ad6 to your computer and use it in GitHub Desktop.
Save kingxsp/e66ae9723c3abbc79434f8f89a370ad6 to your computer and use it in GitHub Desktop.
struct CloningLab {
subjects: Vec<Box<Mammal>>,
}
trait Mammal {
fn walk(&self);
fn run(&self);
}
#[derive(Clone)]
struct Cat {
meow_factor: u8,
purr_factor: u8
}
impl Mammal for Cat {
fn walk(&self) {
println!("Cat::walk");
}
fn run(&self) {
println!("Cat::run")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment