News for hackers. Stuff that matters.
Re:Overview of Rust error handling libraries by AndyKelley on Saturday November 23, 2019 @06:09PM (#21617250)
By default this feature is enabled in the Debug build mode only, so its perf impact isn't a concern in release builds. But that being said, the function call only happens in the error path, when returning an error from a function, right? Are you concerned about the perf of the error path? Maybe I'm not understanding something about your implementation. But yeah the way to be sure is to profile. When I get around to it I'll add a flag to allow enabling this feature in release builds and do some profiling.
Re:Overview of Rust error handling libraries by wallacoloo on Saturday November 23, 2019 @08:09PM (#21617687)
> But that being said, the function call only happens in the error path, when returning an error from a function, right?

std::ops::Try looks like: - fn into_result(self) -> Result<Self::Ok, Self::Error>; // called on `x` whenever you use the `x?` syntax. - fn from_error(v: Self::Error) -> Self; - fn from_ok(v: Self::Ok) -> Self;

It's been a while since I explored this. I was thinking you'd `#[inline(always)]` the `into_result` method, but now that I look at the trait again, I think you would only force inline the `from_error` method and it should still work but without impacting the non-error path much.