Skip to content

Commit

Permalink
Implement as_slice and as_mut_slice methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
c0gent committed Sep 25, 2017
1 parent a990f5d commit 5c6d00e
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 5c6d00e

Please sign in to comment.