Get the latest tech news

Using unwrap() in Rust is Okay (2022)


I blog mostly about my own programming projects.

(Note: anyhow is great for application oriented code, but if one is building a library intended for others to use, I’d suggest writing out concrete error types and providing an appropriate std::fmt::Display impl. Additionally, documentation examples tend to be targeting the demonstration of some particular facet of an API, and expecting them to be perfectly idiomatic in every other aspect—especially if it distracts focus from the point of the example—seems unrealistic. Needing to write expect() and come up with a message, I agree, exercises more brain cells and probably does result in folks thinking more deeply about whether a panic can occur.

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Rust

Rust

Photo of unwrap

unwrap

Related news:

News photo

Writing into Uninitialized Buffers in Rust

News photo

Show HN: Stack Error – ergonomic error handling for Rust

News photo

'Rust is So Good You Can Get Paid $20K to Make It as Fast as C'