title: Reached the type-length limit while instantiating std::vec::IntoIter<i32>
body: <p>I am trying to implement a <code>Tree</code> structure, but I keep getting an error whenever I try to run the following code:</p>
  
  <pre><code>fn main() {
      let tree = Tree::create(1, |_| Vec::new());
      println!("{:?}", tree);
  }
  
  #[derive(Debug)]
  struct Tree&lt;T&gt; {
      value: T,
      children: Vec&lt;Tree&lt;T&gt;&gt;,
  }
  
  impl&lt;T&gt; Tree&lt;T&gt; {
      fn create&lt;F&gt;(value: T, get_children: F) -&gt; Tree&lt;T&gt;
      where
          F: Fn(&amp;T) -&gt; Vec&lt;T&gt;,
      {
          let children = get_children(&amp;value);
          Tree {
              value,
              children: children
                  .into_iter()
                  .map(|x| Tree::create(x, |y| get_children(y)))
                  .collect(),
          }
      }
  }
  </code></pre>
  
  <p>The error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error: reached the type-length limit while instantiating `&lt;std::vec::IntoIter&lt;i32&gt; as std::iter::Iterator&gt;::map::&lt;Tree&lt;i32...`
    |
    = note: consider adding a `#![type_length_limit="2097152"]` attribute to your crate
  </code></pre>