gyscos / zstd-rs

A rust binding for the zstd compression library.
MIT License
510 stars 107 forks source link

WriteBuf documentation is unclear with regards to whether it will reallocate #259

Closed Ten0 closed 6 months ago

Ten0 commented 8 months ago

The WriteBuf documentation says:

This seems to suggest that it would reallocate the buffer as necessary, which ended up causing a bug here: https://github.com/Ten0/serde_avro_fast/pull/11

It might be useful to clarify the documentation to precise that it will not ever reallocate, and that by "growable" and "resizing" we really mean "flagging uninitialized data as initialized by using Vec::set_len, but not actually grow the Vec's allocation".

Thanks,

gyscos commented 6 months ago

Thanks for the report!

Indeed, I understand the documentation is a bit confusing.

I tried to reword it in the latest commit, hope it helps avoid this kind of issues.

Ten0 commented 6 months ago

Seems clear 👍