Skip to content

Commit a90765c

Browse files
author
bors-servo
authored
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 -->
2 parents a990f5d + 5c6d00e commit a90765c

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,20 @@ impl<A: Array> SmallVec<A> {
530530
}
531531
}
532532

533+
/// Extracts a slice containing the entire vector.
534+
///
535+
/// Equivalent to `&mut s[..]`.
536+
pub fn as_slice(&self) -> &[A::Item] {
537+
self
538+
}
539+
540+
/// Extracts a mutable slice of the entire vector.
541+
///
542+
/// Equivalent to `&mut s[..]`.
543+
pub fn as_mut_slice(&mut self) -> &mut [A::Item] {
544+
self
545+
}
546+
533547
/// Remove the element at position `index`, replacing it with the last element.
534548
///
535549
/// This does not preserve ordering, but is O(1).

0 commit comments

Comments
 (0)