1
Fork 0

Simplify ring buffer pushes

This commit is contained in:
David Tolnay 2022-01-18 19:07:12 -08:00
parent e219b2b5f9
commit 50d722a691
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
2 changed files with 12 additions and 7 deletions

View file

@ -22,6 +22,10 @@ impl<T> RingBuffer<T> {
RingBuffer { data: VecDeque::new(), offset: 0 }
}
pub fn push(&mut self, value: T) {
self.data.push_back(value);
}
pub fn advance_right(&mut self)
where
T: Default,
@ -34,6 +38,10 @@ impl<T> RingBuffer<T> {
self.offset += 1;
}
pub fn clear(&mut self) {
self.data.clear();
}
pub fn truncate(&mut self, len: usize) {
self.data.truncate(len);
}