News for hackers. Stuff that matters.
Re:Common Rust Lifetime Misconceptions by farmeroy on Monday December 04, 2023 @10:04PM (#38526593)
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
Re:Common Rust Lifetime Misconceptions by gruelsandwich on Tuesday December 05, 2023 @01:18AM (#38527679)
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
Re:Common Rust Lifetime Misconceptions by satvikpendem on Tuesday December 05, 2023 @07:45AM (#38530046)
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.
Re:Common Rust Lifetime Misconceptions by couchand on Tuesday December 05, 2023 @08:28AM (#38530417)
.unwrap() is the new // TODO:
Re:Common Rust Lifetime Misconceptions by farmeroy on Tuesday December 05, 2023 @02:51PM (#38536051)
for better or worse...
Re:Common Rust Lifetime Misconceptions by jlffwoymasdf on Tuesday December 05, 2023 @05:20PM (#38537730)
I found prototyping with `anyhow` really easy then I can convert to `thiserror` if I'm not interested in the boxing.