Struct rbf::RingBuffer[][src]

pub struct RingBuffer<T, const SIZE: usize> { /* fields omitted */ }

A RingBuffer holds SIZE elements of type T.

Implementations

impl<T: Default + Copy, const SIZE: usize> RingBuffer<T, SIZE>[src]

pub fn new() -> Self[src]

Make a new RingBuffer!

pub fn push_overwrite(&mut self, elem: T) -> Option<T>[src]

Push something onto the buffer. If the buffer is full, the oldest element is returned.

pub fn push_unless_full(&mut self, elem: T) -> Result<(), Error>[src]

Push something onto the buffer, unless the buffer is full.

pub fn pop(&mut self) -> Option<T>[src]

Pop the buffer. If it is empty, then None is returned.

pub fn len(&self) -> usize[src]

How many elements are in the buffer?

pub fn is_empty(&self) -> bool[src]

Is the buffer empty?

pub fn is_full(&self) -> bool[src]

Is the buffer full?

impl<T: Default + Copy, const SIZE: usize> RingBuffer<T, SIZE>[src]

pub fn iter(&self) -> IntoIteratorRingbuffer<'_, T, SIZE>

Notable traits for IntoIteratorRingbuffer<'a, T, SIZE>

impl<'a, T: Default + Copy, const SIZE: usize> Iterator for IntoIteratorRingbuffer<'a, T, SIZE> type Item = &'a T;
[src]

Make an immutable non-consuming iterator

Trait Implementations

impl<T: Default + Copy, const SIZE: usize> Default for RingBuffer<T, SIZE>[src]

impl<T: Default + Copy, const SIZE: usize> IntoIterator for RingBuffer<T, SIZE>[src]

type Item = T

The type of the elements being iterated over.

type IntoIter = ConsumingIntoIteratorRingbuffer<T, SIZE>

Which kind of iterator are we turning this into?

impl<'a, T: Default + Copy, const SIZE: usize> IntoIterator for &'a RingBuffer<T, SIZE>[src]

type Item = &'a T

The type of the elements being iterated over.

type IntoIter = IntoIteratorRingbuffer<'a, T, SIZE>

Which kind of iterator are we turning this into?

Auto Trait Implementations

impl<T, const SIZE: usize> Send for RingBuffer<T, SIZE> where
    T: Send

impl<T, const SIZE: usize> Sync for RingBuffer<T, SIZE> where
    T: Sync

impl<T, const SIZE: usize> Unpin for RingBuffer<T, SIZE> where
    T: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.