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

Add from_raw_parts. #130

Merged
merged 1 commit into from Nov 13, 2018
Merged

Add from_raw_parts. #130

merged 1 commit into from Nov 13, 2018

Conversation

heycam
Copy link
Contributor

@heycam heycam commented Nov 13, 2018

I have a need to create a SmallVec using a heap allocation that I control. Something that works just like Vec::from_raw_parts fits the bill. The PR here adds a similar method, with the important difference that it panics if asked to conjure up a SmallVec that would use its inline storage rather than spilled, heap storage.

This is a dependency of my work in https://bugzilla.mozilla.org/show_bug.cgi?id=1474793.


This change is Reviewable

@heycam heycam requested a review from mbrubeck November 13, 2018 04:30
@emilio
Copy link
Member

emilio commented Nov 13, 2018

Would it be better to unconditionally use from_heap in SmallVec::from_vec? It looks to me like it's pointless to move the data to the stack.

@emilio
Copy link
Member

emilio commented Nov 13, 2018

Oh yeah I guess that wouldn't be safe, nvm

@mbrubeck
Copy link
Collaborator

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 4046724 has been approved by mbrubeck

@bors-servo
Copy link
Contributor

⌛ Testing commit 4046724 with merge 5f80461...

bors-servo pushed a commit that referenced this pull request Nov 13, 2018
Add from_raw_parts.

I have a need to create a `SmallVec` using a heap allocation that I control.  Something that works just like `Vec::from_raw_parts` fits the bill.  The PR here adds a similar method, with the important difference that it panics if asked to conjure up a `SmallVec` that would use its inline storage rather than spilled, heap storage.

This is a dependency of my work in https://bugzilla.mozilla.org/show_bug.cgi?id=1474793.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-smallvec/130)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

☀️ Test successful - status-travis
Approved by: mbrubeck
Pushing 5f80461 to master...

@bors-servo bors-servo merged commit 4046724 into servo:master Nov 13, 2018
mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this pull request Nov 15, 2018
Changes in this release:

* Fix possible over-allocation in `from_slice` (servo#122)
* Optional nightly-only `specialization` feature for `from_slice`
  optimization (servo#123)
* New `from_raw_parts` constructor (servo#130)
* Documentation and testing improvements (servo#125, servo#129)
@mbrubeck mbrubeck mentioned this pull request Nov 15, 2018
bors-servo pushed a commit that referenced this pull request Nov 16, 2018
Version 0.6.6

Changes in this release:

* Fix possible over-allocation in `from_slice` (#122)
* Optional nightly-only `specialization` feature for `from_slice` optimization (#123)
* New `from_raw_parts` constructor (#130)
* Documentation and testing improvements (#125, #129)

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/rust-smallvec/131)
<!-- Reviewable:end -->
@mbrubeck
Copy link
Collaborator

Published: https://crates.io/crates/smallvec/0.6.6

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.

None yet

4 participants