Re:Errors are values
by chrismorgan on Tuesday January 13, 2015 @07:58AM
(#8879461)
I’d also estimate that of all the `write` calls the first is by a considerable margin the most likely to fail.
To be fair, the Rust approach is mostly the same as the Go one on the machine, just harder to screw-up: the discriminant of the enum has to be checked to be able to extract the value (or extract the error) which is similar to checking `err` for `nil`.
If you have to call `write()` 10k times (say, in a loop), and get an error on the first write, instead of either unwinding (in C++) or returning (in Rust), that Go solution requires your program to check for nil 99,999 times.