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

Fix bug in ArrayVec::extend_from_slice #3272

Merged
merged 2 commits into from
Aug 30, 2024

Conversation

tcharding
Copy link
Member

Currently the source slice must be the exact length to fill the array to max capacity, this is an unnecessary restriction since an ArrayVec is a variable sized data structure.

Set the destination slice to be the same length as the source slice (still maintain capacity checks).

Currently the source slice must be the exact length to fill the array to
max capacity, this is an unnecessary restriction since an `ArrayVec` is
a variable sized data structure.

Set the destination slice to be the same length as the source
slice (still maintain capacity checks).
Test that we can extend an `ArrayVec` with a slice that is less than
remaining capacity.
@github-actions github-actions bot added the C-internals PRs modifying the internals crate label Aug 29, 2024
Copy link
Collaborator

@Kixunil Kixunil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 4024ba5

I've known about this bug for a while and I've fixed it (with the same fix) in ~2 PRs/WIPs. Good to see it here separately.

#[test]
fn extend_from_slice() {
let mut av = ArrayVec::<u8, 8>::new();
av.extend_from_slice(b"abc");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to check the content too.

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 4024ba5 successfully ran local tests

@apoelstra apoelstra merged commit 904fefb into rust-bitcoin:master Aug 30, 2024
23 checks passed
@tcharding tcharding deleted the 08-30-array-vec branch September 5, 2024 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-internals PRs modifying the internals crate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants