Skip to content

Replace into_raw_parts/from_raw_parts with into_parts/from_parts - #821

Merged
alejandro-vaz merged 6 commits into
smallvec:v2from
GauravPawar101:rawsmallvec
Oct 30, 2026
Merged

alejandro-vaz merged 6 commits into
smallvec:v2from
GauravPawar101:rawsmallvec

Conversation

@GauravPawar101

Copy link
Copy Markdown
Collaborator

Closes #817

Changes

  • Add into_parts / from_parts taking and returning (RawSmallVec, LocatedLength), which describe both inline and spilled vectors. into_parts_with_allocator / from_parts_with_allocator also carry the allocator.
  • from_parts* are unsafe, with the invariants documented (the tag matches the active union member, the elements are initialized, a spilled buffer has capacity above INLINE and came from the given allocator).
  • Public only with internals (the _with_allocator variants also need allocator-api).
  • Remove into_raw_parts / from_raw_parts.
  • into_iter now uses into_parts_with_allocator, removing an unsafe block.

Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread src/lib.rs Resolved
Comment thread tests/main.rs Resolved
Comment thread tests/main.rs Resolved
@alejandro-vaz

This comment was marked as low quality.

Comment thread tests/allocatorparts.rs Resolved
Comment thread tests/allocatorparts.rs Resolved
Comment thread tests/parts.rs Resolved
Signed-off-by: Gauravpawar101 <Gauravpawar2522@gmail.com>
Signed-off-by: Gauravpawar101 <Gauravpawar2522@gmail.com>
Signed-off-by: Gauravpawar101 <Gauravpawar2522@gmail.com>
Signed-off-by: Gauravpawar101 <Gauravpawar2522@gmail.com>

@alejandro-vaz alejandro-vaz 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.

great, this first part looks really good

now deprecate the four methods like we did on src/macro.rs pointing towards their From conversions that don't yet exist but that I'll add on my PR

@GauravPawar101

Copy link
Copy Markdown
Collaborator Author

provide message

@GauravPawar101

Copy link
Copy Markdown
Collaborator Author

bro, when is that PR going to merge

@alejandro-vaz

Copy link
Copy Markdown
Member

provide message

try to deduce it more or less, if you're not sure leave it empty, I'll make sure they are all fine on v2-rc

bro, when is that PR going to merge

after this one because my PR depends on this PR merging. I now have UB because of how the old parts stuff worked

Signed-off-by: Gauravpawar101 <Gauravpawar2522@gmail.com>
@alejandro-vaz

Copy link
Copy Markdown
Member

failing CI

Signed-off-by: Gauravpawar101 <Gauravpawar2522@gmail.com>
@GauravPawar101

Copy link
Copy Markdown
Collaborator Author

greeen

@alejandro-vaz alejandro-vaz 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.

thanks @GauravPawar101

I'll expand this

@alejandro-vaz
alejandro-vaz added this pull request to the merge queue Oct 30, 2026
Merged via the queue into smallvec:v2 with commit 7cba112 Oct 30, 2026
8 checks passed
@GauravPawar101
GauravPawar101 deleted the rawsmallvec branch November 7, 2026 11:43
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.

refactor into_raw_parts and from_raw_parts and add conversion

2 participants