Skip to content

libcollections: Add append_all_move method to Vec<T>. #15532

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,24 @@ impl<T> Vec<T> {
self
}

/// Takes ownership of the vector `other`, moving all elements into
/// the current vector. Afterwards, the current vector is returned for use
/// again. This does not copy any elements, and it is illegal to use the
///`other` vector after calling this method (because it is moved here).
///
/// # Example
///
/// ```rust
/// let mut vec = vec!(box 1i);
/// let other = vec!(box 2, box 3);
/// assert_eq!(vec.append_move(other), vec!(box 1, box 2, box 3));
/// ```
#[inline]
pub fn append_move(mut self, other: Vec<T>) -> Vec<T> {
self.push_all_move(other);
self
}

/// Shorten a vector, dropping excess elements.
///
/// If `len` is greater than the vector's current length, this has no
Expand Down