kdwarn

Codeberg Mastodon Feeds

Home > Programming > Blog

Made Up of Wires

Subscribe Feeds

Full Posts [switch to table of contents]

tagged: error-handling [clear]

Note: visiting individual posts will show related follow-up and previous posts, if any exist.

'static for error types

January 6, 2024

daybook, rust, error-handling | permalink

A suggestion from Jon Gjengset in the chapter on error handling in Rust for Rustaceans:

Finally, where possible, your error type should be 'static. The most immediate benefit of this is that it allows the caller to more easily propagate your error up the call stack without running into lifetime issues. It also enables your error type to be used more easily with type-erased error types, as we’ll see shortly.