pub struct Trail<T: Copy> { /* private fields */ }Expand description
Fixed-length history of the last n values, e.g. a comet tail (CORE-R29).
A ring buffer over a Vec<T> reserved once: while filling, values are appended;
once full, head marks the oldest slot and each push overwrites it. T: Copy
keeps overwrites trivially cheap and avoids needing T: Default for pre-fill.
Implementations§
Source§impl<T: Copy> Trail<T>
impl<T: Copy> Trail<T>
Sourcepub fn new(n: usize) -> Self
pub fn new(n: usize) -> Self
A trail remembering at most n values; n = 0 keeps nothing (CORE-R29).
Sourcepub fn iter(&self) -> impl DoubleEndedIterator<Item = &T> + '_
pub fn iter(&self) -> impl DoubleEndedIterator<Item = &T> + '_
Values from oldest to newest (CORE-R29).
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn clear(&mut self)
Trait Implementations§
Auto Trait Implementations§
impl<T> Forget for Trail<T>
impl<T> Freeze for Trail<T>
impl<T> Move for Trail<T>
impl<T> RefUnwindSafe for Trail<T>where
Vec<T>: RefUnwindSafe,
impl<T> Send for Trail<T>
impl<T> Sync for Trail<T>
impl<T> Unpin for Trail<T>
impl<T> UnsafeUnpin for Trail<T>where
Vec<T>: UnsafeUnpin,
impl<T> UnwindSafe for Trail<T>where
Vec<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