title: How can I match on a specific io::Error type?
body: <p>I am trying to read in a file until the end 2 bytes at a time and I want to catch the EOF error:</p>
  <pre><code>use byteorder::{BigEndian, ReadBytesExt}; // 1.3.4
  use std::fs::File;
  
  fn main() {
      let filename = &quot;/etc/hosts&quot;;
      let mut file = File::open(filename).expect(&quot;Cannot open file&quot;);
      loop {
          let binary = match file.read_u16::&lt;BigEndian&gt;() {
              Ok(binary) =&gt; binary,
              Err(e) =&gt; panic!(&quot;Can't read from file: {}, err {}&quot;, filename, e),
              // Can I catch the EOF error here?
          };
          println!(&quot;{:?}&quot;, binary);
      }
  }
  </code></pre>