Working on a lil pet project in rust rn and discovered that using Result in the hot path is significantly affecting performance, how do people deal with this?
&mut flag@cas some things i might try:
Error payload, ideally to a single word (e.g. by Box'ing the error)() or a unit-struct struct ErrorType;) and store the error data out-of-band ie in a mutable variable somewhere. this makes the overhead of the result type minimal and makes the destructor a no-op. you could also try a hybrid approach where the error type is a plain enum with error codes, and then extra error metadata like strings are stored out of band#[inline(always)] and outlining cold helpers from the error path may help