diff options
| author | Flying-Toast <38232168+Flying-Toast@users.noreply.github.com> | 2021-07-30 16:01:49 -0400 |
|---|---|---|
| committer | Flying-Toast <38232168+Flying-Toast@users.noreply.github.com> | 2021-07-30 16:01:49 -0400 |
| commit | 9a2e3f3a8e032ae7b39c33bc7cc8f25ebbef8a8e (patch) | |
| tree | a15635245b5f2c0903775162e2456d9c1c8a637a /library/alloc/src/vec | |
| parent | f3f8e758f2b2abd84b76bcb4ec0b6ae263e1e7b9 (diff) | |
| download | rust-9a2e3f3a8e032ae7b39c33bc7cc8f25ebbef8a8e.tar.gz rust-9a2e3f3a8e032ae7b39c33bc7cc8f25ebbef8a8e.zip | |
Recommend `swap_remove` in `Vec::remove` docs
Diffstat (limited to 'library/alloc/src/vec')
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index 06a7c335bf0..61e018285ce 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -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. |
