Skip to content

Comment on Common Rust Lifetime Misconceptions (2020)parent

Comments

Me too. I also do this with .unwrap() - when I'm pretty sure of the happy path - while I'm prototyping. It's pretty easy afterwards to run back through and replace .unwrap() calls with better error handling. But as I improve, I'm getting more in the habit of using matching directly. Understanding lifetimes is probably really helpful for understanding library errors though and I need to go deeper there for sure

This is what I love about Rust, and other languages with these kinds of constructs. You have to acknowledge that something might e.g. fail. You can choose to do "nothing" (e.g. unwrap), but it must be done explicitly, which makes the ignored cases simple to identify later

I used to use OCaml before using Rust, it was similarly great and it's where Rust got the notion of the Option and Result types.

.unwrap() is the new // TODO:

for better or worse...

I found prototyping with `anyhow` really easy then I can convert to `thiserror` if I'm not interested in the boxing.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.