<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="trait Foo: Fn(i32) + Send { }
impl&lt;T:?Sized + Fn(i32) + Send&gt; Foo for T { }

fn wants_foo(t: Box&lt;Foo&gt;) {
}

fn main() {
  let f = Box::new(|x| println!(&quot;{}&quot;, x));
  wants_foo(f);
}"><pre class="notranslate"><span class="pl-k">trait</span> <span class="pl-smi">Foo</span><span class="pl-kos">:</span> <span class="pl-smi">Fn</span><span class="pl-kos">(</span><span class="pl-smi">i32</span><span class="pl-kos">)</span> + <span class="pl-smi">Send</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-smi">T</span><span class="pl-kos">:</span>?<span class="pl-smi">Sized</span> + <span class="pl-smi">Fn</span><span class="pl-kos">(</span><span class="pl-smi">i32</span><span class="pl-kos">)</span> + <span class="pl-smi">Send</span><span class="pl-kos">&gt;</span> <span class="pl-smi">Foo</span> <span class="pl-k">for</span> <span class="pl-smi">T</span> <span class="pl-kos">{</span> <span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">wants_foo</span><span class="pl-kos">(</span><span class="pl-s1">t</span><span class="pl-kos">:</span> <span class="pl-smi">Box</span><span class="pl-kos">&lt;</span><span class="pl-smi">Foo</span><span class="pl-kos">&gt;</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-k">let</span> f = <span class="pl-smi">Box</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span>|x| <span class="pl-en">println</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"{}"</span>, x<span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-en">wants_foo</span><span class="pl-kos">(</span>f<span class="pl-kos">)</span><span class="pl-kos">;</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto">Output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;anon&gt;:9:13: 9:14 error: the value of the associated type `Output` (from the trait `core::ops::FnOnce`) must be specified [E0191]
&lt;anon&gt;:9   wants_foo(f);
                     ^"><pre class="notranslate"><code class="notranslate">&lt;anon&gt;:9:13: 9:14 error: the value of the associated type `Output` (from the trait `core::ops::FnOnce`) must be specified [E0191]
&lt;anon&gt;:9   wants_foo(f);
                     ^
</code></pre></div>
<p dir="auto">cc <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/nikomatsakis/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/nikomatsakis">@nikomatsakis</a></p>
<p dir="auto"><a href="http://static.rust-lang.org/doc/master/std/hash/index.html" rel="nofollow">http://static.rust-lang.org/doc/master/std/hash/index.html</a></p>