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

Feature spare elements #12

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

cehteh
Copy link
Contributor

@cehteh cehteh commented Jan 10, 2025

While my atomic append PR #10 targets appending to a shared headervec through a immutable reference (rather special use case), this implements the std vec like way using a mutable reference to a headervec using the spare capacity as a writable buffer and then completing this by readjusting the len.

note: this includes all work on #10

This is a very early draft. method names and semantic may change.
* introduces a helper union to fix simplify alignment calculations
  no need for cmp and phantom data anymore
* add simple testcase that triggered the miri issue
* change end_ptr_atomic_mut(), using the rewritten start_ptr()
These methods have the same API/Semantic than the std::Vec methods.
They are useful when one wants to extend a HeaderVec in place in some complex way
like for example appending chars to a u8 headervec with `encode_utf8()`
Having a HeaderVec being zero length is mostly useless because it has to reallocated instanly
when anything becomes pushed. This clearly should be avoided!

Nevertheless supporting zero length takes out a corner-case and a potential panic and removes
the burden for users explicitly ensuring zero length HeaderVecs don't happen in
practice. Generally improving software reliability.
@cehteh
Copy link
Contributor Author

cehteh commented Jan 18, 2025

Note: the last commit should go into its own 'feature-std-comatibility' branch. Once #10 that got resolved and merged i will rebase the code here onto that and refactor as needed.
currently pushing ahead and working on everything clobbered together simplifies my work here as i can test everything together.

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

Successfully merging this pull request may close these issues.

1 participant