Pinned ·

Rust: Render `serde` Errors For Humans Using `format_serde_error`

Foreword The serde crate is certainly one of the finest tools in the box. I rarely work on a project that does not make use of it; most of the time it is a user-facing usage - prominently: configuration files. Now, humans make mistakes, and I think software should be blameless an…

Pinned ·

Rust: How to Unwrap Multiple Required Options

Let's say we have a function that returns an Option. fn get_option() -> Option<bool> { Some(true) } We call it in main for this example and print the value using the dbg! macro: fn main() { let b = get_option(); dbg!(b); } This will yield: [src/…