Closed
Description
the code below can be compiled, but it should be rejected because of &mut T is invariant On T;
Is there anything I misunderstand?
impl Animal for Cat1 {
fn snuggle(&self) {
}
fn eat(&mut self) {
println!("cat {}", self.data);
}
}
impl Cat for Cat1 {
fn meow(&self) {}
}
fn love(pet: &mut Animal) {
}
fn change() {
let mut z: Cat1 = Cat1 {
data: 8
};
love(&mut z);
}
Metadata
Metadata
Assignees
Labels
No labels