0

I have a struct A as a container,

struct A {
   children: Vec<T>,
   // other fields
},

a trait T,

trait T {
    // some methods
}

and several implementations of T: B, C, etc.

struct B(_ref_to_A_);
impl T for B {}

I want that, B hold a reference to A while A have B in its children. So how can I change the definition of A and B to achieve my goal.

ooabc
  • 33
  • 4
  • Thanks a lot. I have read that post before asking this question. It told me why rather than how, and I wonder if there is really not any solution, such as `Rc`, `Pin` (I have only a little knowledge of these techniques). – ooabc May 24 '22 at 02:40
  • See the "How to fix it" section. – Chayim Friedman May 24 '22 at 02:43

0 Answers0