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 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
Collaborator

@mbrubeck mbrubeck left a comment

Choose a reason for hiding this comment

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

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)`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

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()));
Copy link
Collaborator

Choose a reason for hiding this comment

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

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

@mbrubeck
Copy link
Collaborator

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 852b817 has been approved by mbrubeck

@bors-servo
Copy link
Contributor

⌛ Testing commit 852b817 with merge 17b68fe...

bors-servo pushed 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

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

@bors-servo bors-servo merged commit 852b817 into servo:master Aug 13, 2018
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 pushed 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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants