|
|
|
|
|
by philosopher1234
1902 days ago
|
|
Whats painful: 1. Extra indentation for both cases, instead of shoving only the error case aside.
2. How do you annotate the error with details of the current function? In go you can write `return fmt.Errorf("parsing point (id=%v): %w", id, err)` and easily add crucial context for devs to understand why an error occurred. This seems harder to do in rust. Calling that a strict improvement is too black and white, and the point of my asking others to name good things about Go is to force a more nuanced conversation. |
|
Of course, the way you'd write fallible_function if you weren't going out of your way to be verbose would be like this:
Separately, the point of all this is to be able to statically know whether a function can fail or not. We know for a fact that fallible_function can fail. If we write a function We know for a fact it won't fail (unless it panics, but well behaved code should never panic). We don't even have to worry about the possibility of nils getting in there and screwing us up.