Struct CircularBuffer

Source
pub struct CircularBuffer<T> { /* private fields */ }

Implementations§

Source§

impl<T> CircularBuffer<T>

Source

pub fn new_zeroed(count: usize) -> CircularBuffer<T>
where T: Zero,

Create a new CircularBuffer<T> by initializing it with T’s Zero implementation.

This function is feature-gated behind the num-traits feature.

Source§

impl<T> CircularBuffer<T>

Source

pub fn new_default(count: usize) -> CircularBuffer<T>
where T: Default,

Create a new CircularBuffer<T> by initializing it with T’s Default implementation.

Source

pub fn update_forwards(&mut self, src: T) -> (T, T)
where T: Copy,

Returns the previous value, and increments cursor

Source

pub fn update_backwards(&mut self, src: T) -> (T, T)
where T: Copy,

The same as CircularBuffer::update_forwards but reverses through the internal buffer

Source

pub const fn set_cursor(&mut self, val: usize)

Set the CircularBuffer’s cursor to the specified value

Source

pub const fn reset_cursor(&mut self)

Set the CircularBuffer’s cursor to zero

Source

pub const fn is_empty(&self) -> bool

Source

pub const fn len(&self) -> usize

Returns the total element-count in this CircularBuffer

Source

pub fn as_slice(&self) -> &[T]

Returns the full data contained in this CircularBuffer as a shared slice-reference

Source

pub fn as_mut_slice(&mut self) -> &mut [T]

Returns the full data contained in this CircularBuffer as a mutable slice-reference

Trait Implementations§

Source§

impl<T> From<ArrayPtr<T>> for CircularBuffer<T>

Source§

fn from(value: ArrayPtr<T>) -> Self

Converts to this type from the input type.
Source§

impl<T> Index<usize> for CircularBuffer<T>

Source§

type Output = <ArrayPtr<T> as Index<usize>>::Output

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<T> IndexMut<usize> for CircularBuffer<T>

Source§

fn index_mut(&mut self, index: usize) -> &mut Self::Output

Performs the mutable indexing (container[index]) operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for CircularBuffer<T>

§

impl<T> RefUnwindSafe for CircularBuffer<T>
where T: RefUnwindSafe,

§

impl<T> !Send for CircularBuffer<T>

§

impl<T> !Sync for CircularBuffer<T>

§

impl<T> Unpin for CircularBuffer<T>

§

impl<T> UnwindSafe for CircularBuffer<T>
where T: RefUnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.