title: Unable to hold/pass reference of parent to the composition object
body: <p>In C++ it would something like <code>struct A</code> is composed of <code>struct B</code> and some function of <code>B</code> takes a pointer to the parent object <code>A</code>. So function of <code>A</code> calling that function of <code>B</code> will simply pass the <code>this</code> pointer to it. I'm trying this in Rust but failing to get it to work - this is what I want to achieve:</p>
  
  <pre class="lang-rust prettyprint-override"><code>struct A&lt;Type: T&gt; {
      composition: Type,
      value: usize,
  }
  
  impl&lt;Type&gt; A&lt;Type&gt; where Type: T {
      fn new(obj: Type) -&gt; A&lt;Type&gt; {
          A {
              composition: obj,
              value: 999,
          }
      }
  
      fn f(&amp;mut self) {
          println!("Value: {:?}", self.value);
      }
  
      fn call(&amp;mut self) {
          self.composition.f(&amp;mut self);
      }
  }
  
  trait T {
      fn f(&amp;mut self, &amp;mut A&lt;Self&gt;);
  }
  
  struct B {
      value: usize,
  }
  
  impl B {
      fn new() -&gt; B {
          B { value: 0, }
      }
  }
  
  impl T for B {
      fn f(&amp;mut self, parent: &amp;mut A&lt;B&gt;) {
          println!("B::f");
          parent.f();
      }
  }
  
  fn main() {
      let objA = A::new(B::new());
  
      // I want call sequence -&gt; A::call() -&gt; B::f() -&gt; A::f()
      objA.call();
  }
  </code></pre>
  
  <p>Note that i require mutability in all the functions although in example above it might seem that <code>&amp;mut self</code> in most function parameters don't make much sense. How do it do this in Rust?</p>