@@ -46,10 +46,15 @@ const MAXIMUM_ZST_CAPACITY: usize = 1 << (64 - 1); // Largest possible power of
4646/// `VecDeque` is a growable ring buffer, which can be used as a double-ended
4747/// queue efficiently.
4848///
49- /// The "default" usage of this type as a queue is to use `push_back` to add to
50- /// the queue, and `pop_front` to remove from the queue. `extend` and `append`
49+ /// The "default" usage of this type as a queue is to use [ `push_back`] to add to
50+ /// the queue, and [ `pop_front`] to remove from the queue. [ `extend`] and [ `append`]
5151/// push onto the back in this manner, and iterating over `VecDeque` goes front
5252/// to back.
53+ ///
54+ /// [`push_back`]: #method.push_back
55+ /// [`pop_front`]: #method.pop_front
56+ /// [`extend`]: #method.extend
57+ /// [`append`]: #method.append
5358#[ stable( feature = "rust1" , since = "1.0.0" ) ]
5459pub struct VecDeque < T > {
5560 // tail and head are pointers into the buffer. Tail always points
@@ -92,13 +97,13 @@ impl<T> Default for VecDeque<T> {
9297}
9398
9499impl < T > VecDeque < T > {
95- /// Marginally more convenient
100+ /// Marginally more convenient.
96101 #[ inline]
97102 fn ptr ( & self ) -> * mut T {
98103 self . buf . ptr ( )
99104 }
100105
101- /// Marginally more convenient
106+ /// Marginally more convenient.
102107 #[ inline]
103108 fn cap ( & self ) -> usize {
104109 if mem:: size_of :: < T > ( ) == 0 {
@@ -109,19 +114,19 @@ impl<T> VecDeque<T> {
109114 }
110115 }
111116
112- /// Turn ptr into a slice
117+ /// Turn ptr into a slice.
113118 #[ inline]
114119 unsafe fn buffer_as_slice ( & self ) -> & [ T ] {
115120 slice:: from_raw_parts ( self . ptr ( ) , self . cap ( ) )
116121 }
117122
118- /// Turn ptr into a mut slice
123+ /// Turn ptr into a mut slice.
119124 #[ inline]
120125 unsafe fn buffer_as_mut_slice ( & mut self ) -> & mut [ T ] {
121126 slice:: from_raw_parts_mut ( self . ptr ( ) , self . cap ( ) )
122127 }
123128
124- /// Moves an element out of the buffer
129+ /// Moves an element out of the buffer.
125130 #[ inline]
126131 unsafe fn buffer_read ( & mut self , off : usize ) -> T {
127132 ptr:: read ( self . ptr ( ) . offset ( off as isize ) )
@@ -133,7 +138,7 @@ impl<T> VecDeque<T> {
133138 ptr:: write ( self . ptr ( ) . offset ( off as isize ) , value) ;
134139 }
135140
136- /// Returns true if and only if the buffer is at capacity
141+ /// Returns true if and only if the buffer is at capacity.
137142 #[ inline]
138143 fn is_full ( & self ) -> bool {
139144 self . cap ( ) - self . len ( ) == 1
@@ -506,12 +511,15 @@ impl<T> VecDeque<T> {
506511 /// given `VecDeque`. Does nothing if the capacity is already sufficient.
507512 ///
508513 /// Note that the allocator may give the collection more space than it requests. Therefore
509- /// capacity can not be relied upon to be precisely minimal. Prefer `reserve` if future
514+ /// capacity can not be relied upon to be precisely minimal. Prefer [ `reserve`] if future
510515 /// insertions are expected.
511516 ///
512517 /// # Panics
513518 ///
514- /// Panics if the new capacity overflows `usize`.
519+ /// Panics if the new capacity overflows [`usize`].
520+ ///
521+ /// [`reserve`]: #method.reserve
522+ /// [`usize`]: ../../std/primitive.usize.html
515523 ///
516524 /// # Examples
517525 ///
@@ -532,7 +540,9 @@ impl<T> VecDeque<T> {
532540 ///
533541 /// # Panics
534542 ///
535- /// Panics if the new capacity overflows `usize`.
543+ /// Panics if the new capacity overflows [`usize`].
544+ ///
545+ /// [`usize`]: ../../std/primitive.usize.html
536546 ///
537547 /// # Examples
538548 ///
@@ -788,7 +798,7 @@ impl<T> VecDeque<T> {
788798 count ( self . tail , self . head , self . cap ( ) )
789799 }
790800
791- /// Returns true if the buffer contains no elements
801+ /// Returns true if the buffer contains no elements.
792802 ///
793803 /// # Examples
794804 ///
@@ -812,14 +822,17 @@ impl<T> VecDeque<T> {
812822 /// consumed until the end.
813823 ///
814824 /// Note 2: It is unspecified how many elements are removed from the deque,
815- /// if the `Drain` value is not dropped, but the borrow it holds expires
816- /// (eg. due to mem::forget).
825+ /// if the [ `Drain`] value is not dropped, but the borrow it holds expires
826+ /// (eg. due to [` mem::forget`] ).
817827 ///
818828 /// # Panics
819829 ///
820830 /// Panics if the starting point is greater than the end point or if
821831 /// the end point is greater than the length of the vector.
822832 ///
833+ /// [`Drain`]: ../../std/collections/vec_deque/struct.Drain.html
834+ /// [`mem::forget`]: ../../std/mem/fn.forget.html
835+ ///
823836 /// # Examples
824837 ///
825838 /// ```
@@ -941,9 +954,11 @@ impl<T> VecDeque<T> {
941954 a. contains ( x) || b. contains ( x)
942955 }
943956
944- /// Provides a reference to the front element, or `None` if the sequence is
957+ /// Provides a reference to the front element, or [ `None`] if the sequence is
945958 /// empty.
946959 ///
960+ /// [`None`]: ../../std/option/enum.Option.html#variant.None
961+ ///
947962 /// # Examples
948963 ///
949964 /// ```
@@ -965,9 +980,11 @@ impl<T> VecDeque<T> {
965980 }
966981 }
967982
968- /// Provides a mutable reference to the front element, or `None` if the
983+ /// Provides a mutable reference to the front element, or [ `None`] if the
969984 /// sequence is empty.
970985 ///
986+ /// [`None`]: ../../std/option/enum.Option.html#variant.None
987+ ///
971988 /// # Examples
972989 ///
973990 /// ```
@@ -993,9 +1010,11 @@ impl<T> VecDeque<T> {
9931010 }
9941011 }
9951012
996- /// Provides a reference to the back element, or `None` if the sequence is
1013+ /// Provides a reference to the back element, or [ `None`] if the sequence is
9971014 /// empty.
9981015 ///
1016+ /// [`None`]: ../../std/option/enum.Option.html#variant.None
1017+ ///
9991018 /// # Examples
10001019 ///
10011020 /// ```
@@ -1017,9 +1036,11 @@ impl<T> VecDeque<T> {
10171036 }
10181037 }
10191038
1020- /// Provides a mutable reference to the back element, or `None` if the
1039+ /// Provides a mutable reference to the back element, or [ `None`] if the
10211040 /// sequence is empty.
10221041 ///
1042+ /// [`None`]: ../../std/option/enum.Option.html#variant.None
1043+ ///
10231044 /// # Examples
10241045 ///
10251046 /// ```
@@ -1046,9 +1067,11 @@ impl<T> VecDeque<T> {
10461067 }
10471068 }
10481069
1049- /// Removes the first element and returns it, or `None` if the sequence is
1070+ /// Removes the first element and returns it, or [ `None`] if the sequence is
10501071 /// empty.
10511072 ///
1073+ /// [`None`]: ../../std/option/enum.Option.html#variant.None
1074+ ///
10521075 /// # Examples
10531076 ///
10541077 /// ```
@@ -1131,9 +1154,11 @@ impl<T> VecDeque<T> {
11311154 unsafe { self . buffer_write ( head, value) }
11321155 }
11331156
1134- /// Removes the last element from a buffer and returns it, or `None` if
1157+ /// Removes the last element from a buffer and returns it, or [ `None`] if
11351158 /// it is empty.
11361159 ///
1160+ /// [`None`]: ../../std/option/enum.Option.html#variant.None
1161+ ///
11371162 /// # Examples
11381163 ///
11391164 /// ```
@@ -1166,10 +1191,12 @@ impl<T> VecDeque<T> {
11661191 ///
11671192 /// This does not preserve ordering, but is O(1).
11681193 ///
1169- /// Returns `None` if `index` is out of bounds.
1194+ /// Returns [ `None`] if `index` is out of bounds.
11701195 ///
11711196 /// Element at index 0 is the front of the queue.
11721197 ///
1198+ /// [`None`]: ../../std/option/enum.Option.html#variant.None
1199+ ///
11731200 /// # Examples
11741201 ///
11751202 /// ```
@@ -1201,10 +1228,12 @@ impl<T> VecDeque<T> {
12011228 ///
12021229 /// This does not preserve ordering, but is O(1).
12031230 ///
1204- /// Returns `None` if `index` is out of bounds.
1231+ /// Returns [ `None`] if `index` is out of bounds.
12051232 ///
12061233 /// Element at index 0 is the front of the queue.
12071234 ///
1235+ /// [`None`]: ../../std/option/enum.Option.html#variant.None
1236+ ///
12081237 /// # Examples
12091238 ///
12101239 /// ```
@@ -1238,7 +1267,7 @@ impl<T> VecDeque<T> {
12381267 ///
12391268 /// # Panics
12401269 ///
1241- /// Panics if `index` is greater than `VecDeque`'s length
1270+ /// Panics if `index` is greater than `VecDeque`'s length.
12421271 ///
12431272 /// # Examples
12441273 ///
@@ -1463,10 +1492,12 @@ impl<T> VecDeque<T> {
14631492 /// Removes and returns the element at `index` from the `VecDeque`.
14641493 /// Whichever end is closer to the removal point will be moved to make
14651494 /// room, and all the affected elements will be moved to new positions.
1466- /// Returns `None` if `index` is out of bounds.
1495+ /// Returns [ `None`] if `index` is out of bounds.
14671496 ///
14681497 /// Element at index 0 is the front of the queue.
14691498 ///
1499+ /// [`None`]: ../../std/option/enum.Option.html#variant.None
1500+ ///
14701501 /// # Examples
14711502 ///
14721503 /// ```
@@ -1709,7 +1740,9 @@ impl<T> VecDeque<T> {
17091740 ///
17101741 /// # Panics
17111742 ///
1712- /// Panics if the new number of elements in self overflows a `usize`.
1743+ /// Panics if the new number of elements in self overflows a [`usize`].
1744+ ///
1745+ /// [`usize`]: ../../std/primitive.usize.html
17131746 ///
17141747 /// # Examples
17151748 ///
0 commit comments