about summary refs log tree commit diff
path: root/library/alloc/src/vec
diff options
context:
space:
mode:
authorKornel <kornel@geekhood.net>2022-01-16 16:51:55 +0000
committerKornel <kornel@geekhood.net>2022-01-16 17:53:05 +0000
commit361ef2aadc3927b170b6fd2a7f3a9d5308eeeaef (patch)
tree4f2ee3654371c2050e69268f5bae75d93be1755f /library/alloc/src/vec
parent48e89b00caa94829a5f07e0f1ecb33bf37431244 (diff)
downloadrust-361ef2aadc3927b170b6fd2a7f3a9d5308eeeaef.tar.gz
rust-361ef2aadc3927b170b6fd2a7f3a9d5308eeeaef.zip
Docs: recommend VecDeque instead of Vec::remove(0)
Diffstat (limited to 'library/alloc/src/vec')
-rw-r--r--library/alloc/src/vec/mod.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index 78f989e730d..16ba5c008cd 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -1372,9 +1372,12 @@ impl<T, A: Allocator> Vec<T, A> {
     ///
     /// 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.
+    /// to be preserved, use [`swap_remove`] instead. If you'd like to remove
+    /// elements from the beginning of the `Vec`, consider using
+    /// [`VecDeque::pop_front`] instead.
     ///
     /// [`swap_remove`]: Vec::swap_remove
+    /// [`VecDeque::pop_front`]: crate::collections::VecDeque::pop_front
     ///
     /// # Panics
     ///
@@ -1735,6 +1738,11 @@ impl<T, A: Allocator> Vec<T, A> {
     /// Removes the last element from a vector and returns it, or [`None`] if it
     /// is empty.
     ///
+    /// If you'd like to pop the first element, consider using
+    /// [`VecDeque::pop_front`] instead.
+    ///
+    /// [`VecDeque::pop_front`]: crate::collections::VecDeque::pop_front
+    ///
     /// # Examples
     ///
     /// ```