Auto merge of #65 - c0gent:as_slice, r=mbrubeck

Implement `as_slice` and `as_mut_slice` methods.

<!-- 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/65)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo
2017-09-25 17:31:23 -05:00
committed by GitHub
+14
View File
@@ -530,6 +530,20 @@ impl<A: Array> SmallVec<A> {
}
}
/// Extracts a slice containing the entire vector.
///
/// Equivalent to `&mut s[..]`.
pub fn as_slice(&self) -> &[A::Item] {
self
}
/// Extracts a mutable slice of the entire vector.
///
/// Equivalent to `&mut s[..]`.
pub fn as_mut_slice(&mut self) -> &mut [A::Item] {
self
}
/// Remove the element at position `index`, replacing it with the last element.
///
/// This does not preserve ordering, but is O(1).