-
Notifications
You must be signed in to change notification settings - Fork 145
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
Add into_inner #115
Conversation
Converts a SmallVec into an array, provided the SmallVec has not been spilled to the heap.
There was a problem hiding this 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)`. |
There was a problem hiding this comment.
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())); |
There was a problem hiding this comment.
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);
@bors-servo r+ |
📌 Commit 852b817 has been approved by |
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 -->
☀️ Test successful - status-travis |
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 -->
Converts a SmallVec into an array, provided the SmallVec has not been spilled to the heap.
Addresses #85.
This change is