title: How do I specify lifetime parameters in an associated type?
body: <p>I have this trait and simple structure:</p>
  
  <pre><code>use std::path::{Path, PathBuf};
  
  trait Foo {
      type Item: AsRef&lt;Path&gt;;
      type Iter: Iterator&lt;Item = Self::Item&gt;;
  
      fn get(&amp;self) -&gt; Self::Iter;
  }
  
  struct Bar {
      v: Vec&lt;PathBuf&gt;,
  }
  </code></pre>
  
  <p>I would like to implement the <code>Foo</code> trait for <code>Bar</code>:</p>
  
  <pre><code>impl Foo for Bar {
      type Item = PathBuf;
      type Iter = std::slice::Iter&lt;PathBuf&gt;;
  
      fn get(&amp;self) -&gt; Self::Iter {
          self.v.iter()
      }
  }
  </code></pre>
  
  <p>However I'm getting this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0106]: missing lifetime specifier
    --&gt; src/main.rs:16:17
     |
  16 |     type Iter = std::slice::Iter&lt;PathBuf&gt;;
     |                 ^^^^^^^^^^^^^^^^^^^^^^^^^ expected lifetime parameter
  </code></pre>
  
  <p>I found no way to specify lifetimes inside that associated type. In particular I want to express that the iterator cannot outlive the <code>self</code> lifetime.</p>
  
  <p>How do I have to modify the <code>Foo</code> trait, or the <code>Bar</code> trait implementation, to make this work?</p>
  
  <p><a href="https://play.rust-lang.org/?gist=b67ee336bf04f71d175a2bab2370d7cf&amp;version=stable&amp;backtrace=0" rel="noreferrer">Rust playground</a></p>