Skip to content

Commit d15a477

Browse files
authored
Rollup merge of rust-lang#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?
2 parents 685027a + 71de148 commit d15a477

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/libcollections/linked_list.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,15 @@
1010

1111
//! A doubly-linked list with owned nodes.
1212
//!
13-
//! The `LinkedList` allows pushing and popping elements at either end and is thus
14-
//! efficiently usable as a double-ended queue.
13+
//! The `LinkedList` allows pushing and popping elements at either end
14+
//! in constant time.
15+
//!
16+
//! Almost always it is better to use `Vec` or [`VecDeque`] instead of
17+
//! [`LinkedList`]. In general, array-based containers are faster,
18+
//! more memory efficient and make better use of CPU cache.
19+
//!
20+
//! [`LinkedList`]: ../linked_list/struct.LinkedList.html
21+
//! [`VecDeque`]: ../vec_deque/struct.VecDeque.html
1522
1623
#![stable(feature = "rust1", since = "1.0.0")]
1724

@@ -27,7 +34,14 @@ use core::ptr::{self, Shared};
2734

2835
use super::SpecExtend;
2936

30-
/// A doubly-linked list.
37+
/// A doubly-linked list with owned nodes.
38+
///
39+
/// The `LinkedList` allows pushing and popping elements at either end
40+
/// in constant time.
41+
///
42+
/// Almost always it is better to use `Vec` or `VecDeque` instead of
43+
/// `LinkedList`. In general, array-based containers are faster,
44+
/// more memory efficient and make better use of CPU cache.
3145
#[stable(feature = "rust1", since = "1.0.0")]
3246
pub struct LinkedList<T> {
3347
head: Option<Shared<Node<T>>>,

0 commit comments

Comments
 (0)