Created
March 6, 2017 23:23
-
-
Save ALSchwalm/fc532dbdae257a03c070d02f7e2b9be1 to your computer and use it in GitHub Desktop.
This file contains 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
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