title: Trouble implementing custom IntoIterator trait
body: <p>I'm new to rust, so forgive me if the question is naive.</p>
  <p>I'm trying to build an OS in rust and I'm following <a href="https://tc.gts3.org/cs3210/2020/spring/lab/lab2.html" rel="nofollow noreferrer">this</a> tutorial. The OS doesn't have memory management yet, so the goal is to build an object which is like a vector in that it can be pushed and popped etc, but it lives on the stack. We do this by initializing it with an array of fixed size. It looks like this:</p>
  <pre><code>#[derive(Debug)]
  pub struct StackVec&lt;'a, T: 'a&gt; {
      storage: &amp;'a mut [T],
      len: usize
  }
  
  impl&lt;'a, T: 'a&gt; StackVec&lt;'a, T&gt; {
  
      pub fn new(storage: &amp;'a mut [T]) -&gt; StackVec&lt;'a, T&gt; {
          StackVec {
              storage: storage,
              len: 0,
          }
      }
  
      pub fn with_len(storage: &amp;'a mut [T], len: usize) -&gt; StackVec&lt;'a, T&gt; {
          if len &gt; storage.len(){
              panic!();
          }
  
          StackVec{
              storage: storage,
              len: len
          }
      }
  
      pub fn capacity(&amp;self) -&gt; usize {
          self.storage.len()
      }
  
      pub fn into_slice(self) -&gt; &amp;'a mut [T] {
          &amp;mut self.storage[0..self.len]
      }
    
      // Other functions which aren't relevant for the question.
  
  }
  </code></pre>
  <p>Popping and pushing increases and decreases the <code>len</code> variable and adds and removes entries from the appropriate place in the array.</p>
  <p>Now, we also need to implement the IntoIterator trait. Given that the <code>StackVec</code> contains a reference to an array, I thought that I could just return an iterator from the underlying array:</p>
  <pre><code>impl &lt;'a, T:'a&gt; IntoIterator for StackVec&lt;'a, T&gt; {
      type Item = T;
      type IntoIter = core::array::IntoIter; // &lt;- Throws &quot;not found in `core::array&quot;
  
      fn into_iter(self) -&gt; Self::IntoIter {
          self.into_slice().into_iter()
      }
  }
  </code></pre>
  <p>But no matter how much I play around with it, it still doesn't want to compile. I can't find a way to express using types that <code>into_iter</code>should return the iterator for the array. What am I doing wrong?</p>