diff options
| author | Steve Klabnik <steve@steveklabnik.com> | 2016-12-24 14:29:21 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-12-24 14:29:21 -0500 |
| commit | d15a47749a7ee1f8bdeb4303e906b4f4bb3d6b81 (patch) | |
| tree | f46aa37e07afa1de208276761ea9d5599fc4d434 | |
| parent | 685027a23e42d272bef63e30848703b9d52e7dfd (diff) | |
| parent | 71de148649bd9d2548b55e5d52bd0c8b38ffec44 (diff) | |
| download | rust-d15a47749a7ee1f8bdeb4303e906b4f4bb3d6b81.tar.gz rust-d15a47749a7ee1f8bdeb4303e906b4f4bb3d6b81.zip | |
Rollup merge of #38297 - matklad:linked-lists-are-not-cool, r=GuillaumeGomez
Advertise Vec in LinkedList docs r? @steveklabnik Hi! We already [advise](https://doc.rust-lang.org/std/collections/#use-a-linkedlist-when) to use `Vec` instead of `LinkedList` in the top-level collections documentation. But I think it may be missed by someone who just directly finds `LinkedList`. What do you feel about advertising `Vec` directly in `LinkedList` docs as well?
| -rw-r--r-- | src/libcollections/linked_list.rs | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs index e8c2e0b5902..31085509088 100644 --- a/src/libcollections/linked_list.rs +++ b/src/libcollections/linked_list.rs @@ -10,8 +10,15 @@ //! A doubly-linked list with owned nodes. //! -//! The `LinkedList` allows pushing and popping elements at either end and is thus -//! efficiently usable as a double-ended queue. +//! The `LinkedList` allows pushing and popping elements at either end +//! in constant time. +//! +//! Almost always it is better to use `Vec` or [`VecDeque`] instead of +//! [`LinkedList`]. In general, array-based containers are faster, +//! more memory efficient and make better use of CPU cache. +//! +//! [`LinkedList`]: ../linked_list/struct.LinkedList.html +//! [`VecDeque`]: ../vec_deque/struct.VecDeque.html #![stable(feature = "rust1", since = "1.0.0")] @@ -27,7 +34,14 @@ use core::ptr::{self, Shared}; use super::SpecExtend; -/// A doubly-linked list. +/// A doubly-linked list with owned nodes. +/// +/// The `LinkedList` allows pushing and popping elements at either end +/// in constant time. +/// +/// Almost always it is better to use `Vec` or `VecDeque` instead of +/// `LinkedList`. In general, array-based containers are faster, +/// more memory efficient and make better use of CPU cache. #[stable(feature = "rust1", since = "1.0.0")] pub struct LinkedList<T> { head: Option<Shared<Node<T>>>, |
