Skip to content

Instantly share code, notes, and snippets.

@ALSchwalm
Created March 6, 2017 23:23
Show Gist options
  • Save ALSchwalm/fc532dbdae257a03c070d02f7e2b9be1 to your computer and use it in GitHub Desktop.
Save ALSchwalm/fc532dbdae257a03c070d02f7e2b9be1 to your computer and use it in GitHub Desktop.
let cat = Cat {
meow_factor: 7
purr_factor: 8
};
let dog = Dog { ... };
let clone_mammal: &CloneMammal;
if get_random_bool() == true {
clone_mammal = &cat;
} else {
clone_mammal = &dog;
}
// Error! How can the compiler know what vtable to
// point to?
let clone: &Clone = &clone_mammal;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment