示例代码:
fn main() {
(T).say();
}
规则一:
1.调用say(self)
2.调用say(&self)
3.调用say(&mut self),如果存在但是self不可变,直接编译失败
4.解引用,如果解引用失败,直接编译失败
5.调用say(self),如果存在但是self没有实现copy,直接编译失败
6.调用say(&self)
7.调用say(&mut self),如果没有实现父类型没有不可变、没有实现DerefMut、或者无法得到&mut,直接编译失败
8.重复4
规则二:
当出现trait实现和本身实现重名时,总是优先调用本身实现