3 comments

  • paaloeye37 minutes ago
    Does ReTangled have anything to do with <a href="https:&#x2F;&#x2F;tangled.org" rel="nofollow">https:&#x2F;&#x2F;tangled.org</a>?
  • LoganDark1 hour ago
    &gt; In Rust you can use ?, which is quicker than unwrap, but you also have to do something like Result&lt;Type, Box&lt;dyn std::error::Error&gt;<p>No, you don&#x27;t! When returning Result&lt;T, E&gt;, you can use ? on any Result&lt;T2, E2&gt; where E: From&lt;E2&gt;. In other words E doesn&#x27;t have to be Box&lt;dyn&gt;, it just has to satisfy From&lt;E2&gt;.<p>Crates like thiserror make it easy to define your own error types that can be easily converted from all the other error types you can encounter in your functions! I do this whenever it doesn&#x27;t make sense to use an inner error type directly, or whenever a function does its own validation that deserves its own error variant.<p>On top of that, I tend to also have error variants for each place in the function rather than only for each type of inner error. At error sites I do something like `.map_err(MyError::PlaceInTheFunction)?` rather than only `?`, and then errors become like a very efficient backtrace :)
    • Graziano_M35 minutes ago
      I think you&#x27;re proving the author&#x27;s point.
      • GreenDolphinSys25 minutes ago
        They&#x27;re saying that you don&#x27;t always have to return Result&lt;T, Box&lt;dyn Error&gt;&gt;, you can implement the From&lt;Error&gt; trait on the type and use ? as usual.<p>In other words implementing that trait lets you set a return type like Result&lt;T, CustomAppError&gt; use ? on it.
        • LoganDark23 minutes ago
          I think they&#x27;re saying the author&#x27;s point is that it&#x27;s more fiddly in Rust (even if there are strong, well-regarded fiddles to use)
          • GreenDolphinSys2 minutes ago
            I don&#x27;t think errors are fiddly in rust. They&#x27;re easy to compose.
          • Graziano_M22 minutes ago
            Yes, and your other part about the crate.<p>&gt; There&#x27;s also Zig-style composable errors with yet another library.
            • LoganDark15 minutes ago
              Ah, it&#x27;s behind a link!<p>While I&#x27;d push back against implying From&lt;E2&gt; is part of the crate, thiserror is an idiomatic approach these days, so I can understand the confusion. I can totally see how they could come to favor Zig if this behavior is &quot;the default&quot;, as opposed to Rust where you&#x27;d usually see it done with &quot;yet another library&quot;.<p>And so I see &quot;the author&#x27;s point&quot; has another meaning now: that Zig-style errors are good :)<p>Edit: oh, after looking into Zig-style errors more, this is actually not how they work! They don&#x27;t nest, they just exist in a global namespace, so they don&#x27;t come with any location data themselves, but you can compose sets of them. Less powerful, but certainly more appealing to some :) I think out-parameters can be used as a side channel for error context.
              • Graziano_M4 minutes ago
                Yeah I 1. wish they were properly composable and 2. think Rust would get less flak if these &#x27;idiomatic&#x27; crates were just pulled into the standard library to avoid some of the dependency mayhem.
      • tcfhgj32 minutes ago
        how so?
  • paaloeye1 hour ago
    $curl: (6) Could not resolve host: gracefulliberty.com HN effect?
    • agumonkey1 hour ago
      <a href="https:&#x2F;&#x2F;archive.is&#x2F;gEZGz" rel="nofollow">https:&#x2F;&#x2F;archive.is&#x2F;gEZGz</a> just in case