diff options
Diffstat (limited to 'compiler/rustc_ast_pretty/src/pp/ring.rs')
-rw-r--r-- | compiler/rustc_ast_pretty/src/pp/ring.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/compiler/rustc_ast_pretty/src/pp/ring.rs b/compiler/rustc_ast_pretty/src/pp/ring.rs index 62900ddfa2d..86b87614c19 100644 --- a/compiler/rustc_ast_pretty/src/pp/ring.rs +++ b/compiler/rustc_ast_pretty/src/pp/ring.rs @@ -26,13 +26,6 @@ impl<T> RingBuffer<T> { self.data.push_back(value); } - pub fn advance_right(&mut self) - where - T: Default, - { - self.data.push_back(T::default()); - } - pub fn advance_left(&mut self) { self.data.pop_front().unwrap(); self.offset += 1; @@ -41,6 +34,14 @@ impl<T> RingBuffer<T> { pub fn clear(&mut self) { self.data.clear(); } + + pub fn last(&self) -> Option<&T> { + self.data.back() + } + + pub fn last_mut(&mut self) -> Option<&mut T> { + self.data.back_mut() + } } impl<T> Index<usize> for RingBuffer<T> { |