diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index f4d0763421c7616bc121a7ec23b34441044c3143..19488ee9f85434e46bffa30abf5f62b6883f8536 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -249,29 +249,17 @@ fn push_front(&mut self, elt: T) { fn pop_front(&mut self) -> Option { self.pop_front_node().map(|box Node{value, ..}| value) } +} - /// Add an element last in the list - /// - /// O(1) - #[deprecated = "use the `push` method"] - fn push_back(&mut self, elt: T) { +impl MutableSeq for DList { + fn push(&mut self, elt: T) { self.push_back_node(box Node::new(elt)) } - - /// Remove the last element and return it, or None if the list is empty - /// - /// O(1) - #[deprecated = "use the `pop` method"] - fn pop_back(&mut self) -> Option { + fn pop(&mut self) -> Option { self.pop_back_node().map(|box Node{value, ..}| value) } } -impl MutableSeq for DList { - fn push(&mut self, elt: T) { self.push_back(elt) } - fn pop(&mut self) -> Option { self.pop_back() } -} - impl Default for DList { #[inline] fn default() -> DList { DList::new() } diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 1d1907f454193cc32e72825d4e8d05b5e81a4c39..8d008f921da17c4f5c9975484e9f1087c3038968 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -516,7 +516,7 @@ pub trait Deque : MutableSeq { /// assert_eq!(d.front(), Some(&1i)); /// ``` #[deprecated = "use the `push` method"] - fn push_back(&mut self, elt: T); + fn push_back(&mut self, elt: T) { self.push(elt) } /// Remove the last element and return it, or `None` if the sequence is empty. /// @@ -534,7 +534,7 @@ pub trait Deque : MutableSeq { /// assert_eq!(d.pop_back(), None); /// ``` #[deprecated = "use the `pop` method"] - fn pop_back(&mut self) -> Option; + fn pop_back(&mut self) -> Option { self.pop() } /// Remove the first element and return it, or `None` if the sequence is empty. /// diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index 9d24b349c975c05afe47844a4158fee4c36e77bb..c56781ec30b72c45ed07f0317b8a5dfd79bbb940 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -80,18 +80,6 @@ fn pop_front(&mut self) -> Option { result } - /// Remove and return the last element in the RingBuf, or None if it is empty - #[deprecated = "use the `pop` method"] - fn pop_back(&mut self) -> Option { - if self.nelts > 0 { - self.nelts -= 1; - let hi = self.raw_index(self.nelts); - self.elts.get_mut(hi).take() - } else { - None - } - } - /// Prepend an element to the RingBuf fn push_front(&mut self, t: T) { if self.nelts == self.elts.len() { @@ -103,10 +91,10 @@ fn push_front(&mut self, t: T) { *self.elts.get_mut(self.lo) = Some(t); self.nelts += 1u; } +} - /// Append an element to the RingBuf - #[deprecated = "use the `push` method"] - fn push_back(&mut self, t: T) { +impl MutableSeq for RingBuf { + fn push(&mut self, t: T) { if self.nelts == self.elts.len() { grow(self.nelts, &mut self.lo, &mut self.elts); } @@ -114,11 +102,15 @@ fn push_back(&mut self, t: T) { *self.elts.get_mut(hi) = Some(t); self.nelts += 1u; } -} - -impl MutableSeq for RingBuf { - fn push(&mut self, t: T) { self.push_back(t) } - fn pop(&mut self) -> Option { self.pop_back() } + fn pop(&mut self) -> Option { + if self.nelts > 0 { + self.nelts -= 1; + let hi = self.raw_index(self.nelts); + self.elts.get_mut(hi).take() + } else { + None + } + } } impl Default for RingBuf {