Skip to content

Commit

Permalink
Rollup merge of rust-lang#35181 - GuillaumeGomez:vec_doc, r=steveklabnik
Browse files Browse the repository at this point in the history
Add doc example for Vec

Fixes rust-lang#29380.

r? @steveklabnik
  • Loading branch information
GuillaumeGomez committed Aug 5, 2016
2 parents 27118ac + 1fa9b8d commit a935bda
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,25 @@ impl<T> Vec<T> {
/// Note that this will drop any excess capacity. Calling this and
/// converting back to a vector with `into_vec()` is equivalent to calling
/// `shrink_to_fit()`.
///
/// # Examples
///
/// ```
/// let v = vec![1, 2, 3];
///
/// let slice = v.into_boxed_slice();
/// ```
///
/// Any excess capacity is removed:
///
/// ```
/// let mut vec = Vec::with_capacity(10);
/// vec.extend([1, 2, 3].iter().cloned());
///
/// assert_eq!(vec.capacity(), 10);
/// let slice = vec.into_boxed_slice();
/// assert_eq!(slice.into_vec().capacity(), 3);
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn into_boxed_slice(mut self) -> Box<[T]> {
unsafe {
Expand Down

0 comments on commit a935bda

Please sign in to comment.