<story><title>Things I Enjoy in Rust: Error Handling</title><url>https://blog.jonstodle.com/things-i-enjoy-in-rust-error-handling/</url></story><parent_chain><item><author>wyldfire</author><text>One of the more interesting semi-recent additions to stable rust is the question mark operator.  It&amp;#x27;s not covered in this Rust Error Handling article, but it&amp;#x27;s got some of the early-exit appeal of exceptions without too much unwind magic.&lt;p&gt;Unfortunately I haven&amp;#x27;t been able to get the question mark operator to work yet with my code, but it looks appealing.  It&amp;#x27;s not 100% obvious to me what qualities my Result type needs in order to be able to make it work.  Or whether it&amp;#x27;s bound in practice to the Result type(s) defined in std.  I&amp;#x27;m sure those details are all in the docs somewhere but I spent the time to look yet.</text></item></parent_chain><comment><author>CUViper</author><text>One thing you may be missing is that the `Result::Err` in your return type must implement `From` for the `Result::Err` type where you&amp;#x27;re using the `?` operator. That&amp;#x27;s already covered if those `Err` types are identical (`From&amp;lt;T&amp;gt; for T`), otherwise you need to implement the conversion.&lt;p&gt;&lt;pre&gt;&lt;code&gt;    impl From&amp;lt;QuestionError&amp;gt; for ReturnError {
        fn from(error: QuestionError) -&amp;gt; ReturnError {
            &amp;#x2F;&amp;#x2F; TODO
            unimplemented!()
        }
    }&lt;/code&gt;&lt;/pre&gt;</text></comment>
<story><title>Things I Enjoy in Rust: Error Handling</title><url>https://blog.jonstodle.com/things-i-enjoy-in-rust-error-handling/</url></story><parent_chain><item><author>wyldfire</author><text>One of the more interesting semi-recent additions to stable rust is the question mark operator.  It&amp;#x27;s not covered in this Rust Error Handling article, but it&amp;#x27;s got some of the early-exit appeal of exceptions without too much unwind magic.&lt;p&gt;Unfortunately I haven&amp;#x27;t been able to get the question mark operator to work yet with my code, but it looks appealing.  It&amp;#x27;s not 100% obvious to me what qualities my Result type needs in order to be able to make it work.  Or whether it&amp;#x27;s bound in practice to the Result type(s) defined in std.  I&amp;#x27;m sure those details are all in the docs somewhere but I spent the time to look yet.</text></item></parent_chain><comment><author>Falell</author><text>The ? operator is tied to std::ops::Try, and std::convert::From. &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;doc.rust-lang.org&amp;#x2F;std&amp;#x2F;ops&amp;#x2F;trait.Try.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;doc.rust-lang.org&amp;#x2F;std&amp;#x2F;ops&amp;#x2F;trait.Try.html&lt;/a&gt; &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;doc.rust-lang.org&amp;#x2F;std&amp;#x2F;convert&amp;#x2F;trait.From.html&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;doc.rust-lang.org&amp;#x2F;std&amp;#x2F;convert&amp;#x2F;trait.From.html&lt;/a&gt;</text></comment>