title: Testing for ErrorKind from a Box<dyn Error>
body: <p>I've got this function that I want to test:</p>
  <pre class="lang-rust prettyprint-override"><code>pub fn run(config: Config) -&gt; Result&lt;(), Box&lt;dyn Error&gt;&gt; {
      let contents = fs::read_to_string(config.filename)?;
      // -- snip
      Ok(())
  }
  </code></pre>
  <p>And this test:</p>
  <pre class="lang-rust prettyprint-override"><code>#[test]
  fn error_for_missing_file() {
      let error = run(Config {
          query: String::from(&quot;query&quot;),
          filename: String::from(&quot;not_a_real_file.txt&quot;),
      })
      .unwrap_err();
  
      let kind = error.kind(); // no method named `kind` found for struct `Box&lt;dyn std::error::Error&gt;` in the current scope
     // assert to follow
  }
  </code></pre>
  <p>How can I get the <code>ErrorKind</code> from a Box?</p>