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 into_inner #115

Merged
merged 3 commits into from Aug 13, 2018
Merged

Add into_inner #115

merged 3 commits into from Aug 13, 2018

Conversation

@1tgr
Copy link
Contributor

1tgr commented Aug 11, 2018

Converts a SmallVec into an array, provided the SmallVec has not been spilled to the heap.

Addresses #85.


This change is Reviewable

Converts a SmallVec into an array, provided the SmallVec has not been spilled to the heap.
Copy link
Contributor

mbrubeck left a comment

Thanks! A couple of change requests below:

lib.rs Outdated
@@ -812,6 +821,19 @@ impl<A: Array> SmallVec<A> {
}
}

/// If the SmallVec has not spilled onto the heap, convert it into an `A`. Otherwise return `Err(Self)`.

This comment has been minimized.

@mbrubeck

mbrubeck Aug 13, 2018

Contributor

This should return an error if self.len() != A::size(). Otherwise it could return uninitialized data if the vector is too short.

lib.rs Outdated
Err(self)
} else {
unsafe {
let data = mem::replace(&mut self.data, SmallVecData::from_inline(mem::uninitialized()));

This comment has been minimized.

@mbrubeck

mbrubeck Aug 13, 2018

Contributor

This could be shortened to let data = ptr::read(&self.data);

@mbrubeck
Copy link
Contributor

mbrubeck commented Aug 13, 2018

@bors-servo
Copy link
Contributor

bors-servo commented Aug 13, 2018

📌 Commit 852b817 has been approved by mbrubeck

@bors-servo
Copy link
Contributor

bors-servo commented Aug 13, 2018

Testing commit 852b817 with merge 17b68fe...

bors-servo added a commit that referenced this pull request Aug 13, 2018
Add into_inner

Converts a SmallVec into an array, provided the SmallVec has not been spilled to the heap.

Addresses #85.

<!-- 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/115)
<!-- Reviewable:end -->
@bors-servo
Copy link
Contributor

bors-servo commented Aug 13, 2018

☀️ Test successful - status-travis
Approved by: mbrubeck
Pushing 17b68fe to master...

@bors-servo bors-servo merged commit 852b817 into servo:master Aug 13, 2018
2 checks passed
2 checks passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
homu Test successful
Details
mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this pull request Aug 22, 2018
Change log:

* servo#118 - optimize `from_slice`
* servo#115 - add `into_inner` method
* Some code cleanup and testing improvements (servo#112, servo#113, servo#114, servo#120)
mbrubeck added a commit to mbrubeck/rust-smallvec that referenced this pull request Aug 22, 2018
Change log:

* servo#115 - add `into_inner` method
* servo#117 - add `from_buf_and_len` and `from_buf_and_len_unchecked`
* servo#118 - optimize `from_slice`
* Some code cleanup and testing improvements (servo#112, servo#113, servo#114, servo#120)
@mbrubeck mbrubeck mentioned this pull request Aug 22, 2018
bors-servo added a commit that referenced this pull request Aug 22, 2018
Version 0.6.5

Change log:

* #115 - add `into_inner` method
* #117 - add `from_buf_and_len` and `from_buf_and_len_unchecked`
* #118 - optimize `from_slice`
* Some code cleanup and testing improvements (#112, #113, #114, #120)

cc @llogiq

<!-- 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/121)
<!-- Reviewable:end -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.