Is there a way to simplify converting an Option into a Result without a macro?
<p>I have something like this (the real function is <code>Ini::Section::get</code> from <a href="https://github.com/zonyitoo/rust-ini" rel="noreferrer">rust-ini</a>):</p>

<pre><code>impl Foo {
    pub fn get&lt;K&gt;(&amp;'a mut self, key: &amp;K) -&gt; Option&lt;&amp;'a str&gt;
    where
        K: Hash + Eq,
    {
        // ...
    }
}
</code></pre>

<p>I have to call it several times:</p>

<pre><code>fn new() -&gt; Result&lt;Boo, String&gt; {
    let item1 = match section.get("item1") {
        None =&gt; return Result::Err("no item1".to_string()),
        Some(v) =&gt; v,
    };
    let item2 = match section.get("item2") {
        None =&gt; return Result::Err("no item2".to_string()),
        Some(v) =&gt; v,
    };
}
</code></pre>

<p>To remove code bloat, I can write a macro like this:</p>

<pre><code>macro_rules! try_ini_get {
    ($e:expr) =&gt; {
        match $e {
            Some(s) =&gt; s,
            None =&gt; return Result::Err("no ini item".to_string()),
        }
    }
}
</code></pre>

<p>Is there any way to remove the code duplication without this macro implementation?</p>