title: How do I idiomatically convert a bool to an Option or Result in Rust?
body: <p>It seems there is no way of such one-line conversion using <code>std</code>.</p>
  <p>I do not like this kind of verbosity:</p>
  <pre class="lang-rust prettyprint-override"><code>match my_bool {
      true =&gt; Ok(()),
      false =&gt; Err(MyError::False),
  }
  </code></pre>
  <p>I would like to use a one-liner, for example:</p>
  <pre class="lang-rust prettyprint-override"><code>let my_bool = true;
  let my_option = my_bool.to_option(MyObject{}); // true =&gt; MyObject{}, false =&gt; None
  let my_result = my_bool.to_result(MyObject{}, MyError{}); // true =&gt; MyObject{}, false =&gt; MyError{}
  </code></pre>
  <p>What is the shortest piece of code for doing that?</p>