Pushes a new value into the buffer, overwriting the oldest value if the buffer is full Returns the value that was overwritten, if any
(&mut self, value: T)
| 32 | /// |
| 33 | /// Returns the value that was overwritten, if any |
| 34 | pub fn push(&mut self, value: T) -> Option<T> { |
| 35 | let popped = if self.is_full() { |
| 36 | self.buffer.pop_front() |
| 37 | } else { |
| 38 | None |
| 39 | }; |
| 40 | self.buffer.push_back(value); |
| 41 | popped |
| 42 | } |
| 43 | |
| 44 | /// Pops a value from the tail |
| 45 | /// |