borgo
borgo copied to clipboard
Can io.Reader's Read safely return Result<int>?
The definition of Read in io.Reader is currently fn Read (p: [byte]) -> Result<int>. I believe this limits it to returning only one of the number of bytes read or an error. But this does not reflect what Read does. From go's docs, Read "returns the number of bytes read (0 <= n <= len(p)) and any error encountered" (emphasis added). There is further discussion of this in several golang-nuts threads such as this one.
(Apologies if I misunderstood something here. I know more go than rust, and I ended up here thanks to an interesting-sounding link from go weekly news.)
You're totally correct! Most bindings are generated automatically and I suspect there are a few more instances of cases like this. At the moment, the compiler struggles a bit with functions that return multiple values where all values are meaningful (such in this case). Shouldn't be too hard to fix though.