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

Change std.io.bit_writer.BitWriter.flushBits() to return the number of unused filled bits #22166

Open
f35f22fan opened this issue Dec 6, 2024 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior

Comments

@f35f22fan
Copy link

Zig Version

0.14.0-dev.2384+cbc05e0b1

Steps to Reproduce and Observed Behavior

Currently the method returns !void

Expected Behavior

Make it return the number of unused filled bits, that is an !u8 which according to the source code would equal to "8 - self.count".
Because to figure this out on your own one needs to read the source code and I'm not sure how future proof it is since it's not documented in the public std API.
My case - I'm creating a Zig UTF-8 string library [1] and when saving multiple Strings consecutively in binary format to disk they don't naturally pan out to byte boundaries. I could compute the bits between them but it's extra lines of (possible error-prone) code and more wasted CPU cycles.
In the API it's not documented, so one has to go to the source code to figure out how many unused bits are between 2 consecutive writes with or without flushes.

I'm not sure if this qualifies as an API bug or some type of request for enhancement.
If this report is inappropriate please just delete it.

[1] https://github.com/f35f22fan/ZigString

@f35f22fan f35f22fan added the bug Observed behavior contradicts documented or intended behavior label Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior
Projects
None yet
Development

No branches or pull requests

1 participant