Result is more flexible than just the question mark
Result is more flexible than just the question mark
Posted Sep 20, 2024 19:37 UTC (Fri) by NYKevin (subscriber, #129325)In reply to: Result is more flexible than just the question mark by tialaramex
Parent article: Best practices for error handling in kernel Rust
It is generally considered polite to impl Debug on all public types. The compiler even has an off-by-default warning for failing to do so: https://doc.rust-lang.org/rustc/lints/listing/allowed-by-...
More pragmatically, if you impl std::error::Error (or core::error::Error in nostd environments), then you must also impl Display and Debug to satisfy its trait bounds. Strictly speaking, Result does not require the Err type to impl that trait, but it is the usual way of doing things.