Skip to content

Commit

Permalink
Recommend swap_remove in Vec::remove docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Flying-Toast committed Jul 30, 2021
1 parent f3f8e75 commit 9a2e3f3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,12 @@ impl<T, A: Allocator> Vec<T, A> {
/// Removes and returns the element at position `index` within the vector,
/// shifting all elements after it to the left.
///
/// Note: Because this shifts over the remaining elements, it has a
/// worst-case performance of O(n). If you don't need the order of elements
/// to be preserved, use [`swap_remove`] instead.
///
/// [`swap_remove`]: Vec::swap_remove
///
/// # Panics
///
/// Panics if `index` is out of bounds.
Expand Down

0 comments on commit 9a2e3f3

Please sign in to comment.