Creates a new ring buffer with the given capacity
(capacity: NonZeroUsize)
| 21 | impl<T> RingBuffer<T> { |
| 22 | /// Creates a new ring buffer with the given capacity |
| 23 | pub fn new(capacity: NonZeroUsize) -> Self { |
| 24 | let capacity = capacity.get(); |
| 25 | Self { |
| 26 | buffer: VecDeque::with_capacity(capacity), |
| 27 | capacity, |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | /// Pushes a new value into the buffer, overwriting the oldest value if the buffer is full |
| 32 | /// |