Skip to content

Instantly share code, notes, and snippets.

View ALSchwalm's full-sized avatar

Adam Schwalm ALSchwalm

View GitHub Profile
trait CloneMammal: Clone + Mammal{}
impl<T> CloneMammal for T where T: Clone + Mammal{}
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;
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.