Struct circularing::Circular
source · pub struct Circular<T, const N: usize>{ /* private fields */ }Implementations§
source§impl<T, const N: usize> Circular<T, N>
impl<T, const N: usize> Circular<T, N>
sourcepub const fn new() -> Self
pub const fn new() -> Self
Construct a new Circular from the grounds up.
Panics: In debug builds, it will panic if N is zero. In release builds attempting to build a zero-length buffer is strictly undefined behaviour.
sourcepub const unsafe fn from_raw_parts(
storage_slice: [MaybeUninit<T>; N],
storage_usage: usize
) -> Self
pub const unsafe fn from_raw_parts( storage_slice: [MaybeUninit<T>; N], storage_usage: usize ) -> Self
Construct a new Circular from the ground up using raw parts.
Panics: In debug builds, it will panic if N is zero. In release builds attempting to build a zero-length buffer is strictly undefined behaviour.
sourcepub fn push(&mut self, target_item: T)
pub fn push(&mut self, target_item: T)
Adds an item T at the end of the buffer and shifts any existing ones forward.
sourcepub fn pop(&mut self) -> Option<T>
pub fn pop(&mut self) -> Option<T>
Removes an item T from the end of the buffer and shifts any existing ones backwards. The resulting value must be used.
pub fn at(&mut self, target_index: usize) -> Option<T>
sourcepub const fn is_nonempty(&self) -> bool
pub const fn is_nonempty(&self) -> bool
Determines if the buffer is non-empty.
Trait Implementations§
Auto Trait Implementations§
impl<T, const N: usize> Freeze for Circular<T, N>where
T: Freeze,
impl<T, const N: usize> RefUnwindSafe for Circular<T, N>where
T: RefUnwindSafe,
impl<T, const N: usize> Send for Circular<T, N>where
T: Send,
impl<T, const N: usize> Sync for Circular<T, N>where
T: Sync,
impl<T, const N: usize> Unpin for Circular<T, N>where
T: Unpin,
impl<T, const N: usize> UnwindSafe for Circular<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