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

Calling EncoderStringWriter::write successively does not equal EncoderStringWriter::write_all #247

Closed
nascent-harry opened this issue Aug 25, 2023 · 2 comments
Assignees

Comments

@nascent-harry
Copy link

The problem

From the docs it seems like using EncoderStringWriter::write incrementally and EncoderStringWriter::write_all once should produce the same result.

This is not the case as seen in the following example:

https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=5ec7ce07f0bd526e7cb8272134eff351

@nascent-harry nascent-harry changed the title Calling EncoderStringWriter::write all successively does not equal EncoderStringWriter::write_all Calling EncoderStringWriter::write successively does not equal EncoderStringWriter::write_all Aug 26, 2023
@marshallpierce
Copy link
Owner

Hm, that doesn't seem great. Thanks for the report; I'll look into it.

@marshallpierce marshallpierce self-assigned this Aug 26, 2023
@marshallpierce
Copy link
Owner

The issue is that the third write() call isn't consuming all of the input, which is per the spec. It only consumes the first two bytes. If you call write() again with the remaining un-used input, all is well: https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=a0770eb15be84f64778143d78e8b500a. I'll also add a test to ensure this works.

marshallpierce added a commit that referenced this issue Aug 26, 2023
Making sure that
#247 is not actually
a bug.
marshallpierce added a commit that referenced this issue Aug 26, 2023
Making sure that
#247 is not actually
a bug.
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