title: Rust panic unit test - specifics of matching the error message
body: <p>I'm looking for a way to assert that a piece of code panics, and that the panic message contains a particular string. I came up with the following which appears to work:</p>
  
  <pre class="lang-rust prettyprint-override"><code>let actual = std::panic::catch_unwind(|| decode(notation.to_string()));
  assert!(actual.is_err());
  let err = *(actual.unwrap_err().downcast::&lt;String&gt;().unwrap());
  assert!(err.contains("Invalid"));
  </code></pre>
  
  <p>I know that I can use <code>#[should_panic]</code> and that it lets me specify a message to check for, but I only want to partially match the exact error message.</p>