by ribasushi · 6y ago · 0 comments
I am not familiar with Rust, but looking around the docs on Read [https://doc.rust-lang.org/std/io/trait.Read.html#errors] I see:
> If an error is returned then it must be guaranteed that no bytes were read.
Could someone elaborate how a system can satisfy this guarantee, seems impossible...?
NormalRead | ShortRead | Error
This case is also an example of why go’s idiom of using error value or return value doesn’t always work.
If you had a maybe type and a general sum type it would be clear when a function was going to return either or both.
Value Error ValueAndError