r/rust • • Sep 24 '24

Rust, Autism, and Correct Code

https://youtu.be/MZdxbf0_fPg?si=fdThISrw6ubN1mXK
186 Upvotes

150 comments sorted by

View all comments

Show parent comment

2

u/shponglespore Sep 25 '24

I'd say in those situations, the absence of a value isn't an error, so there are no details to be reported using an error value. Those are the same kind of situations where you'd use Option rather than Result in Rust, or Maybe rather than Either in Haskell, etc.

2

u/syklemil Sep 25 '24

But that just maps to a regular old nullable T in Go, doesn't it, not (T, bool)? If all you need is to represent a fallible get that sometimes has nothing, there's no need for the second value. And if there is a need to return some error information, doing it with a boolean is pretty crap.

It kind of comes off as if they're trying to approximate an Option<Option<T>>. I guess the usecase is something like "you got a nil here, but that's actually what the value is, don't quit whatever you were doing"?

2

u/shponglespore Sep 25 '24

I guess the usecase is something like "you got a nil here, but that's actually what the value is, don't quit whatever you were doing"?

Bingo. That exact scenario came up in a coding interview I did earlier this week.