title: Implement IntoIterator for binary tree
body: <p>I am trying to build a binary tree and write an iterator to traverse values in the tree.
  When implementing the IntoIterator trait for my tree nodes I ran into a problem with lifetimes</p>
  
  <pre><code>src\main.rs:43:6: 43:8 error: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates [E0207]
  src\main.rs:43 impl&lt;'a, T: 'a&gt; IntoIterator for Node&lt;T&gt; {
  </code></pre>
  
  <p>I understand that I need to specify that NodeIterator will live as long as Node but I am unsure of how to express that</p>
  
  <pre><code>use std::cmp::PartialOrd;
  use std::boxed::Box;
  
  struct Node&lt;T: PartialOrd&gt; {
      value: T,
      left: Option&lt;Box&lt;Node&lt;T&gt;&gt;&gt;,
      right: Option&lt;Box&lt;Node&lt;T&gt;&gt;&gt;,
  }
  
  struct NodeIterator&lt;'a, T: 'a + PartialOrd&gt; {
      current: &amp;'a Node&lt;T&gt;,
      parent: Option&lt;&amp;'a Node&lt;T&gt;&gt;,
  }
  
  impl&lt;T: PartialOrd&gt; Node&lt;T&gt; {
      pub fn insert(&amp;mut self, value: T) {
          ...
      }
  }
  
  impl&lt;'a, T: 'a&gt; IntoIterator for Node&lt;T&gt; { // line 43
       type Item = T;
       type IntoIter = NodeIterator&lt;'a, T&gt;;
  
       fn into_iter(&amp;self) -&gt; Self::IntoIter {
           NodeIterator::&lt;'a&gt; {
               current: Some(&amp;self),
               parent: None
           }
       }
   }
  </code></pre>