Something like:
trait Thingy {
fn hallo(&self);
}
trait Factory {
fn make(&self) -> Thingy;
}
//------------------------------
struct AThingy {}
impl Thingy for AThingy {
fn hallo(&self) {
println!("i'm A thingy");
}
}
struct AFactory {}
impl Factory for AFactory {
fn make(&self) -> AThingy {
AThingy{}
}
}
//------------------------------
struct BThingy {}
impl Thingy for BThingy {
fn hallo(&self) {
println!("i'm B thingy");
}
}
struct BFactory {}
impl Factory for BFactory {
fn make(&self) -> BThingy {
BThingy{}
}
}
//------------------------------
#[test]
fn test_factory() {
let aFactory:Factory = AFactory{};
let bFactory:Factory = BFactory{};
aFactory.make().hallo();
bFactory.make().hallo();
}
tried to attach Sized at various places but all fails.