<p dir="auto">This code: (<a href="http://is.gd/tif86V" rel="nofollow">http://is.gd/tif86V</a>)</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="struct Iter&lt;'a&gt;(&amp;'a mut Vec&lt;int&gt;);

impl&lt;'a&gt; Iterator&lt;&amp;'a mut int&gt; for Iter&lt;'a&gt; {
    fn next(&amp;mut self) -&gt; Option&lt;&amp;'a mut int&gt; {
        self.0.as_mut_slice().get_mut(0)
    }
}"><pre class="notranslate"><span class="pl-k">struct</span> <span class="pl-smi">Iter</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">a</span> <span class="pl-k">mut</span> <span class="pl-smi">Vec</span><span class="pl-kos">&lt;</span><span class="pl-smi">int</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">impl</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span> <span class="pl-smi">Iterator</span><span class="pl-kos">&lt;</span><span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">a</span> <span class="pl-k">mut</span> <span class="pl-smi">int</span><span class="pl-kos">&gt;</span> <span class="pl-k">for</span> <span class="pl-smi">Iter</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">next</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-k">mut</span> <span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Option</span><span class="pl-kos">&lt;</span><span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">a</span> <span class="pl-k">mut</span> <span class="pl-smi">int</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-smi">self</span><span class="pl-kos">.</span><span class="pl-c1">0</span><span class="pl-kos">.</span><span class="pl-en">as_mut_slice</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">get_mut</span><span class="pl-kos">(</span><span class="pl-c1">0</span><span class="pl-kos">)</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Produces this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;anon&gt;:5:16: 5:30 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements
&lt;anon&gt;:5         self.0.as_mut_slice().get_mut(0)
                        ^~~~~~~~~~~~~~
&lt;anon&gt;:4:5: 6:6 help: consider using an explicit lifetime parameter as shown: fn next(&amp;'a mut self) -&gt; Option&lt;&amp;'a mut int&gt;
&lt;anon&gt;:4     fn next(&amp;mut self) -&gt; Option&lt;&amp;'a mut int&gt; {
&lt;anon&gt;:5         self.0.as_mut_slice().get_mut(0)
&lt;anon&gt;:6     }"><pre class="notranslate"><code class="notranslate">&lt;anon&gt;:5:16: 5:30 error: cannot infer an appropriate lifetime for autoref due to conflicting requirements
&lt;anon&gt;:5         self.0.as_mut_slice().get_mut(0)
                        ^~~~~~~~~~~~~~
&lt;anon&gt;:4:5: 6:6 help: consider using an explicit lifetime parameter as shown: fn next(&amp;'a mut self) -&gt; Option&lt;&amp;'a mut int&gt;
&lt;anon&gt;:4     fn next(&amp;mut self) -&gt; Option&lt;&amp;'a mut int&gt; {
&lt;anon&gt;:5         self.0.as_mut_slice().get_mut(0)
&lt;anon&gt;:6     }
</code></pre></div>
<p dir="auto">I don't think there is anything unsafe with what I want to do (it's the exact same signature as <code class="notranslate">MutItems</code>).</p>
<p dir="auto">This code does work but is incompatible with the <code class="notranslate">Iterator</code> trait definition: (<a href="http://is.gd/rMwbe6" rel="nofollow">http://is.gd/rMwbe6</a>)</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="struct Iter&lt;'a&gt;(&amp;'a mut Vec&lt;int&gt;);

impl&lt;'a&gt; Iter&lt;'a&gt; {
    fn next&lt;'c: 'a&gt;(&amp;'c mut self) -&gt; Option&lt;&amp;'a mut int&gt; {
        self.0.as_mut_slice().get_mut(0)
    }
}"><pre class="notranslate"><span class="pl-k">struct</span> <span class="pl-smi">Iter</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">a</span> <span class="pl-k">mut</span> <span class="pl-smi">Vec</span><span class="pl-kos">&lt;</span><span class="pl-smi">int</span><span class="pl-kos">&gt;</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">impl</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span> <span class="pl-smi">Iter</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">fn</span> <span class="pl-en">next</span><span class="pl-kos">&lt;</span><span class="pl-c1">'</span><span class="pl-ent">c</span><span class="pl-kos">:</span> <span class="pl-c1">'</span><span class="pl-ent">a</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">c</span> <span class="pl-k">mut</span> <span class="pl-smi">self</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Option</span><span class="pl-kos">&lt;</span><span class="pl-c1">&amp;</span><span class="pl-c1">'</span><span class="pl-ent">a</span> <span class="pl-k">mut</span> <span class="pl-smi">int</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
        <span class="pl-smi">self</span><span class="pl-kos">.</span><span class="pl-c1">0</span><span class="pl-kos">.</span><span class="pl-en">as_mut_slice</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">get_mut</span><span class="pl-kos">(</span><span class="pl-c1">0</span><span class="pl-kos">)</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Sorry if this is a duplicate.</p>
<p dir="auto">On top of the new I/O subsystem (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="9478273" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/4248" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/4248/hovercard" href="https://github.com/rust-lang/rust/issues/4248">#4248</a>) build an easy to use HTTP client and server library. I want to demo something very simple to use like Go's HTTP library. Needs a lot of research still to figure out what to do here.</p>