Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can io.Reader's Read safely return Result<int>? #21

Open
MichaelUrman opened this issue May 8, 2024 · 1 comment
Open

Can io.Reader's Read safely return Result<int>? #21

MichaelUrman opened this issue May 8, 2024 · 1 comment

Comments

@MichaelUrman
Copy link

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.)

@alpacaaa
Copy link
Contributor

alpacaaa commented May 9, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants