Here is pseu-do codes:
struct A { v: Vec<i32> }
struct B { v: Vec<i32> }
trait C {
fn get(&self) -> &Vec<i32> or Vec<&Vec<i32>>;
}
impl C for A {
fn get(&self) -> &Vec<i32> {
&self.v
}
}
impl C for B {
fn get(&self) -> Vec<&Vec<i32>> {
vec![&self.v, &self.v]
}
}
I tried this, but it does not work:
trait C {
type Output;
fn get(&self) -> Self::Output;
}
impl C for A {
type Output = &Vec<i32>;
fn get(&self) -> Self::Output {
&self.v
}
}
impl C for B {
type Output = Vec<&Vec<i32>>;
fn get(&self) -> Self::Output {
vec![&self.v, &self.v]
}
}
How can I get to that?