title: How can I use Result::expect to log a message before panicking?
body: <p><a href="https://doc.rust-lang.org/std/result/enum.Result.html#method.expect" rel="nofollow noreferrer"><code>Result::expect</code></a> panics with the given message. However, I'd like to log before panicking. Assuming I have used <a href="https://crates.io/crates/log" rel="nofollow noreferrer">log</a> facade and an implementation, I'd like to do something as:</p>
  
  <pre class="lang-rust prettyprint-override"><code>// a result called `result`
  result.something_like_expect(|e| {
      // assuming `e` is an error instance and implements `Display`
      error!("An error happened: {}", e);
      // and panics here
  });
  </code></pre>
  
  <p>Is there such a solution using Rust 1.39.0?</p>