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
trait CloneMammal: Clone + Mammal{} | |
impl<T> CloneMammal for T where T: Clone + Mammal{} |
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 | |
}; | |
// No problem, a CloneMammal is impl for Cat | |
let clone_mammal: &CloneMammal = cat; | |
// Error! | |
let clone: &Clone = &clone_mammal; |
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; |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
OlderNewer