mirror of
https://github.com/openharmony/third_party_rust_rust-smallvec.git
synced 2026-07-21 01:55:25 -04:00
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:
@@ -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).
|
||||
|
||||
Reference in New Issue
Block a user