pub struct RingBuf<T: Copy, const N: usize> { /* private fields */ }Expand description
A fixed-capacity FIFO ring buffer.
A buffer with storage size N can hold at most N - 1 values.
Implementations§
Source§impl<T: Copy, const N: usize> RingBuf<T, N>
impl<T: Copy, const N: usize> RingBuf<T, N>
Sourcepub const fn max_capacity(&self) -> usize
pub const fn max_capacity(&self) -> usize
Returns the maximum number of values the buffer can hold.
Sourcepub fn try_push(&mut self, value: T) -> Result<(), T>
pub fn try_push(&mut self, value: T) -> Result<(), T>
Appends a value, returning it when the buffer is full.
Sourcepub unsafe fn push_unchecked(&mut self, value: T)
pub unsafe fn push_unchecked(&mut self, value: T)
Appends a value without checking whether the buffer is full.
§Safety
The caller must ensure the buffer is not full.
Trait Implementations§
impl<T: Copy + Copy, const N: usize> Copy for RingBuf<T, N>
Auto Trait Implementations§
impl<T, const N: usize> Freeze for RingBuf<T, N>
impl<T, const N: usize> RefUnwindSafe for RingBuf<T, N>
impl<T, const N: usize> Send for RingBuf<T, N>
impl<T, const N: usize> Sync for RingBuf<T, N>
impl<T, const N: usize> Unpin for RingBuf<T, N>
impl<T, const N: usize> UnsafeUnpin for RingBuf<T, N>
impl<T, const N: usize> UnwindSafe for RingBuf<T, N>
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