thin-vec icon indicating copy to clipboard operation
thin-vec copied to clipboard

Initialize the header before calling `set_cap()`/`set_len()`

Open jacob-greenfield opened this issue 1 year ago • 0 comments

Inside header_with_capacity(), the calls to set_cap() and set_len() seem to create a mutable ref to uninitialized data. This change uses std::ptr::write() to avoid creating a reference until the header is initialized. This seems possibly more future-proof in case of any changes to rustc.

jacob-greenfield avatar Sep 07 '24 22:09 jacob-greenfield