<p dir="auto">code:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="pub fn str_join(strs: &amp;[AsRef&lt;str&gt;], join: str) -&gt; String {
    strs.iter().fold(String::new(), |mut acc, s| {
        if !acc.is_empty() { acc.push_str(join); }
        acc.push_str(s);
        acc
    });
}

fn main() {}"><pre class="notranslate"><span class="pl-k">pub</span> <span class="pl-k">fn</span> <span class="pl-en">str_join</span><span class="pl-kos">(</span><span class="pl-s1">strs</span><span class="pl-kos">:</span> <span class="pl-c1">&amp;</span><span class="pl-kos">[</span><span class="pl-smi">AsRef</span><span class="pl-kos">&lt;</span><span class="pl-smi">str</span><span class="pl-kos">&gt;</span><span class="pl-kos">]</span><span class="pl-kos">,</span> <span class="pl-s1">join</span><span class="pl-kos">:</span> <span class="pl-smi">str</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">String</span> <span class="pl-kos">{</span>
    strs<span class="pl-kos">.</span><span class="pl-en">iter</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">fold</span><span class="pl-kos">(</span><span class="pl-smi">String</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">,</span> |<span class="pl-k">mut</span> acc<span class="pl-kos">,</span> s| <span class="pl-kos">{</span>
        <span class="pl-k">if</span> !acc<span class="pl-kos">.</span><span class="pl-en">is_empty</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span> acc<span class="pl-kos">.</span><span class="pl-en">push_str</span><span class="pl-kos">(</span>join<span class="pl-kos">)</span><span class="pl-kos">;</span> <span class="pl-kos">}</span>
        acc<span class="pl-kos">.</span><span class="pl-en">push_str</span><span class="pl-kos">(</span>s<span class="pl-kos">)</span><span class="pl-kos">;</span>
        acc
    <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">main</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span><span class="pl-kos">}</span></pre></div>
<p dir="auto">message:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;anon&gt;:2:10: 2:16 error: no method named `iter` found for type `&amp;[core::convert::AsRef&lt;str&gt;]` in the current scope
&lt;anon&gt;:2     strs.iter().fold(String::new(), |mut acc, s| {
                  ^~~~~~
&lt;anon&gt;:2:10: 2:16 note: the method `iter` exists but the following trait bounds were not satisfied: `core::convert::AsRef&lt;str&gt; : core::marker::Sized`, `core::convert::AsRef&lt;str&gt; : core::marker::Sized`
&lt;anon&gt;:1:38: 1:42 error: the trait `core::marker::Sized` is not implemented for the type `str` [E0277]
&lt;anon&gt;:1 pub fn str_join(strs: &amp;[AsRef&lt;str&gt;], join: str) -&gt; String {
                                              ^~~~
&lt;anon&gt;:1:38: 1:42 note: `str` does not have a constant size known at compile-time
&lt;anon&gt;:1 pub fn str_join(strs: &amp;[AsRef&lt;str&gt;], join: str) -&gt; String {
                                              ^~~~
&lt;anon&gt;:3:13: 3:27 error: the type of this value must be known in this context
&lt;anon&gt;:3         if !acc.is_empty() { acc.push_str(join); }
                     ^~~~~~~~~~~~~~
note: in expansion of closure expansion
&lt;anon&gt;:2:37: 6:6 note: expansion site
error: aborting due to 3 previous errors
playpen: application terminated with error code 101"><pre class="notranslate"><code class="notranslate">&lt;anon&gt;:2:10: 2:16 error: no method named `iter` found for type `&amp;[core::convert::AsRef&lt;str&gt;]` in the current scope
&lt;anon&gt;:2     strs.iter().fold(String::new(), |mut acc, s| {
                  ^~~~~~
&lt;anon&gt;:2:10: 2:16 note: the method `iter` exists but the following trait bounds were not satisfied: `core::convert::AsRef&lt;str&gt; : core::marker::Sized`, `core::convert::AsRef&lt;str&gt; : core::marker::Sized`
&lt;anon&gt;:1:38: 1:42 error: the trait `core::marker::Sized` is not implemented for the type `str` [E0277]
&lt;anon&gt;:1 pub fn str_join(strs: &amp;[AsRef&lt;str&gt;], join: str) -&gt; String {
                                              ^~~~
&lt;anon&gt;:1:38: 1:42 note: `str` does not have a constant size known at compile-time
&lt;anon&gt;:1 pub fn str_join(strs: &amp;[AsRef&lt;str&gt;], join: str) -&gt; String {
                                              ^~~~
&lt;anon&gt;:3:13: 3:27 error: the type of this value must be known in this context
&lt;anon&gt;:3         if !acc.is_empty() { acc.push_str(join); }
                     ^~~~~~~~~~~~~~
note: in expansion of closure expansion
&lt;anon&gt;:2:37: 6:6 note: expansion site
error: aborting due to 3 previous errors
playpen: application terminated with error code 101
</code></pre></div>
<p dir="auto">in particular, the 'not satisifed' trait bounds has two duplicated results:</p>
<blockquote>
<p dir="auto">note: the method <code class="notranslate">iter</code> exists but the following trait bounds were not satisfied: <code class="notranslate">core::convert::AsRef&lt;str&gt; : core::marker::Sized</code>, `core::convert::AsRef : core::marker::Sized``</p>
</blockquote>
<p dir="auto">this currently happens on the beta and nightly release channels (stable doesn't display this message at all)</p>
<p dir="auto"><a href="http://is.gd/iEs3Nq" rel="nofollow">playpen link</a></p>
<p dir="auto">At present, fd_set is defined as libnative::io::c::fd_set, on both Windows and Linux. However, I can't use this, as it's not made "pub mod c" in <a href="https://github.com/rust-lang/rust/blob/8bb34a3146e6ba4bc7902a85de90cf4f8064ace0/src/libnative/io/mod.rs">mod.rs</a>.</p>
<p dir="auto">I'm writing a binding from a C network-related library (libircclient) to Rust, and would like fd_set to be available without having to duplicate effort.</p>