struct
如何实现特征方法,还可以调用该方法的默认版本?
pub trait MyTrait {
fn do_it(&self) {
println!("I am doing it the default way.");
}
}
pub struct MyStruct;
impl MyTrait for MyStruct {
fn do_it(&self) {
println!("Doing it my way.");
//Call default method
self.MyTrait::do_it(); //Not worky
}
}
fn main() {
let m = MyStruct;
m.do_it();
}