Recommend swap_remove in Vec::remove docs

This commit is contained in:
Flying-Toast 2021-07-30 16:01:49 -04:00
parent f3f8e758f2
commit 9a2e3f3a8e

View File

@ -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.