Skip to content

Commit

Permalink
Auto merge of #65 - c0gent:as_slice, r=mbrubeck
Browse files Browse the repository at this point in the history
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 -->
  • Loading branch information
bors-servo authored Sep 25, 2017
2 parents a990f5d + 5c6d00e commit a90765c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down

0 comments on commit a90765c

Please sign in to comment.