pub struct RingBuf<T: Copy + Default, const N: usize> { /* private fields */ }Expand description
A ring buffer of N elements stored entirely on the stack.
Once full, new pushes overwrite the oldest entry. Iteration with
iter() yields elements from oldest to newest.
Implementations§
Source§impl<T: Copy + Default, const N: usize> RingBuf<T, N>
impl<T: Copy + Default, const N: usize> RingBuf<T, N>
Sourcepub fn push(&mut self, val: T)
pub fn push(&mut self, val: T)
Append a value, overwriting the oldest entry once the ring is full.
This never fails and never blocks; if losing the oldest entry is not
acceptable, use crate::EventBuf, whose push reports when full.
Sourcepub fn is_full(&self) -> bool
pub fn is_full(&self) -> bool
Returns true if the ring is at capacity, so the next
push will overwrite the oldest entry.
Trait Implementations§
Auto Trait Implementations§
impl<T, const N: usize> Freeze for RingBuf<T, N>where
T: Freeze,
impl<T, const N: usize> RefUnwindSafe for RingBuf<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Send for RingBuf<T, N>where
T: Send,
impl<T, const N: usize> Sync for RingBuf<T, N>where
T: Sync,
impl<T, const N: usize> Unpin for RingBuf<T, N>where
T: Unpin,
impl<T, const N: usize> UnsafeUnpin for RingBuf<T, N>where
T: UnsafeUnpin,
impl<T, const N: usize> UnwindSafe for RingBuf<T, N>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more