Sometime, we want to Implement some method with other mod struct, it need write two statement block:
mod block1{
pub structA;
}
mod block2{
use super::block1::structA;
trait MyTrait {
fn foo(self);
}
impl MyTrait for structA {
fn foo(self){
println!("this is foo method");
}
}
}
I think it can be integrated into this way:
mod block1{
pub structA;
}
mod block2{
use super::block1::structA;
trait MyTrait for structA {
fn foo(self){
println!("this is foo method");
}
}
pub trait MyTrait2 for structA {
fn foo2(self){
println!("this is foo method");
}
}
}
Is there any problem in doing this?