<p dir="auto">When trying to spawn several thousand tasks on OS X 10.9.4 I get this error (duplicate a few dozen times at once):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="task '&lt;unnamed&gt;' failed at 'could not initialize task_rng: couldn't open file (Too many open files; path=/dev/urandom; mode=open; access=read)', /opt/local/var/macports/build/_opt_mports_dports_lang_rust/rust/work/rust/src/libstd/rand/mod.rs:342"><pre class="notranslate"><code class="notranslate">task '&lt;unnamed&gt;' failed at 'could not initialize task_rng: couldn't open file (Too many open files; path=/dev/urandom; mode=open; access=read)', /opt/local/var/macports/build/_opt_mports_dports_lang_rust/rust/work/rust/src/libstd/rand/mod.rs:342
</code></pre></div>
<p dir="auto">Reproducible for me with this code:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
fn process_errors() {
  let path = &quot;file.log&quot;;
  let mut file = BufferedReader::new(File::open(&amp;Path::new(path)));
  let lines: Vec&lt;String&gt; = file.lines().map(|x| x.unwrap()).collect();
  let len = lines.len();
  let sharedLines = Arc::new(lines);
  let (tx, rx) = channel();

  for i in range(0, len) {
    let share = sharedLines.clone();
    let tx = tx.clone();

    spawn(proc() {
      let s = (*share)[i].as_slice();
      let decoded: ErrorJson = json::decode(s).ok().expect(format!(&quot;failed to parse line {}&quot;, s).as_slice());
      let re = regex!(r&quot;needed string (.+) other string&quot;);
      for caps in re.captures_iter(decoded.message.as_slice()) {
        tx.send(caps.at(1).to_string());
        return;
      }

      tx.send(&quot;&quot;.to_string());
    });
  }
}"><pre class="notranslate"><span class="pl-k">fn</span> <span class="pl-en">process_errors</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
  <span class="pl-k">let</span> path = <span class="pl-s">"file.log"</span><span class="pl-kos">;</span>
  <span class="pl-k">let</span> <span class="pl-k">mut</span> file = <span class="pl-smi">BufferedReader</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-smi">File</span><span class="pl-kos">::</span><span class="pl-en">open</span><span class="pl-kos">(</span><span class="pl-c1">&amp;</span><span class="pl-smi">Path</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span>path<span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">let</span> lines<span class="pl-kos">:</span> <span class="pl-smi">Vec</span><span class="pl-kos">&lt;</span><span class="pl-smi">String</span><span class="pl-kos">&gt;</span> = file<span class="pl-kos">.</span><span class="pl-en">lines</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">map</span><span class="pl-kos">(</span>|x| x<span class="pl-kos">.</span><span class="pl-en">unwrap</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">collect</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">let</span> len = lines<span class="pl-kos">.</span><span class="pl-en">len</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">let</span> sharedLines = <span class="pl-smi">Arc</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span>lines<span class="pl-kos">)</span><span class="pl-kos">;</span>
  <span class="pl-k">let</span> <span class="pl-kos">(</span>tx<span class="pl-kos">,</span> rx<span class="pl-kos">)</span> = <span class="pl-en">channel</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

  <span class="pl-k">for</span> i <span class="pl-k">in</span> <span class="pl-en">range</span><span class="pl-kos">(</span><span class="pl-c1">0</span><span class="pl-kos">,</span> len<span class="pl-kos">)</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> share = sharedLines<span class="pl-kos">.</span><span class="pl-en">clone</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-k">let</span> tx = tx<span class="pl-kos">.</span><span class="pl-en">clone</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

    <span class="pl-en">spawn</span><span class="pl-kos">(</span><span class="pl-en">proc</span><span class="pl-kos">(</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
      <span class="pl-k">let</span> s = <span class="pl-kos">(</span><span class="pl-c1">*</span>share<span class="pl-kos">)</span><span class="pl-kos">[</span>i<span class="pl-kos">]</span><span class="pl-kos">.</span><span class="pl-en">as_slice</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-k">let</span> decoded<span class="pl-kos">:</span> <span class="pl-smi">ErrorJson</span> = json<span class="pl-kos">::</span><span class="pl-en">decode</span><span class="pl-kos">(</span>s<span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">ok</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">expect</span><span class="pl-kos">(</span><span class="pl-en">format</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">"failed to parse line {}"</span>, s<span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">as_slice</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-k">let</span> re = <span class="pl-en">regex</span><span class="pl-en">!</span><span class="pl-kos">(</span><span class="pl-s">r"needed string (.+) other string"</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
      <span class="pl-k">for</span> caps <span class="pl-k">in</span> re<span class="pl-kos">.</span><span class="pl-en">captures_iter</span><span class="pl-kos">(</span>decoded<span class="pl-kos">.</span><span class="pl-c1">message</span><span class="pl-kos">.</span><span class="pl-en">as_slice</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
        tx<span class="pl-kos">.</span><span class="pl-en">send</span><span class="pl-kos">(</span>caps<span class="pl-kos">.</span><span class="pl-en">at</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">.</span><span class="pl-en">to_string</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
        <span class="pl-k">return</span><span class="pl-kos">;</span>
      <span class="pl-kos">}</span>

      tx<span class="pl-kos">.</span><span class="pl-en">send</span><span class="pl-kos">(</span><span class="pl-s">""</span><span class="pl-kos">.</span><span class="pl-en">to_string</span><span class="pl-kos">(</span><span class="pl-kos">)</span><span class="pl-kos">)</span><span class="pl-kos">;</span>
    <span class="pl-kos">}</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"><code class="notranslate">file.log</code> contains a few thousand lines of <code class="notranslate">"\n"</code>-separated JSON objects.</p>
<p dir="auto">Output of <code class="notranslate">rustc --version</code>:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="rustc 0.12.0-pre (5fb2dfaa2 2014-08-25 12:10:56 +0000)"><pre class="notranslate"><code class="notranslate">rustc 0.12.0-pre (5fb2dfaa2 2014-08-25 12:10:56 +0000)
</code></pre></div>
<p dir="auto">This is an unnecessary corner of the language, the only remaining use of the <code class="notranslate">check</code> keyword. I know I have misexplained the difference between <code class="notranslate">alt</code> and <code class="notranslate">alt check</code> before.</p>
<p dir="auto"><code class="notranslate">alt check</code> is a bit of an anti-pattern because it:</p>
<ul dir="auto">
<li>Indicates that enums aren't factored correctly. With case classes we should have more control to prevent this kind of problem.</li>
<li>Encourages non-exhaustive matches which are only discovered at runtime.</li>
<li>Doesn't provide any documentation about why other cases don't matter.</li>
</ul>
<p dir="auto">Which is clearer?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="alt check foo {
    bar =&gt; baz
}"><pre class="notranslate"><code class="notranslate">alt check foo {
    bar =&gt; baz
}
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="alt foo {
    bar =&gt; baz,
    _ =&gt; fail &quot;this shouldn't happen because ...&quot;
}"><pre class="notranslate"><code class="notranslate">alt foo {
    bar =&gt; baz,
    _ =&gt; fail "this shouldn't happen because ..."
}
</code></pre></div>
<p dir="auto">The first requires explaination. The second says exactly what the fallthrough behavior is, occurs syntactically where the fallthrough behavior occurs, and is more natural to write (once you've written all the cases you intend to cover you then write the fallthrough case instead of going back to the top of the structure and changing it).</p>