Skip to content

feat: Implement extend from slice on SoAVec - #38

Merged
aapoalas merged 2 commits into
mainfrom
add_extend_from_slice_api
Oct 6, 2025
Merged

feat: Implement extend from slice on SoAVec#38
aapoalas merged 2 commits into
mainfrom
add_extend_from_slice_api

Conversation

@Reinsdyret

@Reinsdyret Reinsdyret commented Oct 1, 2025

Copy link
Copy Markdown
Collaborator

extend_from_slice for SoAVec
uses T::TupleReps::write to write each element from slice into self.buf and then update length.

Closes #25

@Reinsdyret

Copy link
Copy Markdown
Collaborator Author

Unsure about the runtime here if its O(slice.len()) or O(slice.len() * num_fields) depends on into tuple i think

@Reinsdyret
Reinsdyret requested a review from aapoalas October 1, 2025 07:53
@aapoalas

aapoalas commented Oct 6, 2025

Copy link
Copy Markdown
Member

Unsure about the runtime here if its O(slice.len()) or O(slice.len() * num_fields) depends on into tuple i think

The tuple is (using the derive macro, and under any reasonable custom implementation) determined by the number of fields in the original struct. O(slice.len() * num_fields) is correct (although someone might argue that that's the case for a normal Vec as well; they'd be both right and wrong).

@aapoalas aapoalas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, and praise for a nice set of tests as well! <3

@aapoalas
aapoalas merged commit 46795bb into main Oct 6, 2025
3 checks passed
@aapoalas
aapoalas deleted the add_extend_from_slice_api branch October 6, 2025 18:27
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.

extend_from_slice API

2 participants