<p dir="auto">One can't cast static data to a static pointer to a trait. This seems like a valid corner case that should be implemented.</p>
<p dir="auto">I had a brief chat on IRC today about adding support for deducing the function return type. I realize we decided against doing this a couple years ago, but I think it's worth revisiting in light of iterators. One of the challenges with our iterators is that the types of complex iterators are unwieldy. For example, here's the type of chaining two vecs together:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="type T&lt;'self&gt; = std::iter::Chain&lt;
    std::vec::VecIterator&lt;'self, int&gt;,
    std::vec::VecIterator&lt;'self, int&gt;
&gt;;

fn main() {
    let x = [1,2,3];
    let y = [4,5,6];
    let iter: T = x.iter().chain(y.iter());
}"><pre class="notranslate"><code class="notranslate">type T&lt;'self&gt; = std::iter::Chain&lt;
    std::vec::VecIterator&lt;'self, int&gt;,
    std::vec::VecIterator&lt;'self, int&gt;
&gt;;

fn main() {
    let x = [1,2,3];
    let y = [4,5,6];
    let iter: T = x.iter().chain(y.iter());
}
</code></pre></div>
<p dir="auto">While we can generally rely on type inference inside a function, things get really messy once we try to return an iterator from a function. One way to avoid this complicated type is to box of the iterators inside a <code class="notranslate">~Iterator&lt;int&gt;</code>, but according to <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/thestinger/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/thestinger">@thestinger</a>, this is ~1000x slower than with a monomorphized iterator. Having return type deduction would make it much easier to pass around iterators.</p>
<p dir="auto">This would also be really handy for macros and syntax extensions. For example, we could convert the serialize.rs over to iterators without needing generators (<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="19409280" data-permission-text="Title is private" data-url="https://github.com/rust-lang/rust/issues/9145" data-hovercard-type="issue" data-hovercard-url="/rust-lang/rust/issues/9145/hovercard" href="https://github.com/rust-lang/rust/issues/9145">#9145</a>).</p>
<p dir="auto">This has been proposed for (C++14)[http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3638.html].</p>
<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/cmr/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/cmr">@cmr</a> had an argument against this. He felt that adding return type deduction would make it that much easier to break ABIs.</p>