pub struct RollingSum<T, const WINDOW: usize> { /* private fields */ }Implementations§
Source§impl<T, const WINDOW: usize> RollingSum<T, WINDOW>where
T: Default,
impl<T, const WINDOW: usize> RollingSum<T, WINDOW>where
T: Default,
Source§impl<T, const WINDOW: usize> RollingSum<T, WINDOW>
impl<T, const WINDOW: usize> RollingSum<T, WINDOW>
Sourcepub fn add(&mut self, val: T)
pub fn add(&mut self, val: T)
Adds T to the rolling sum, displacing the oldest
member if the window is full to capacity.
If adding T causes numerical overflow, subsequent
calls to total will return None until window
expirations cause underflow commensurate to the overflow.
§Panics
This function panics if the usize variable tracking the
number of times the sum has overflowed itself overflows.
A window should be sized such that this never occurs.
Trait Implementations§
Auto Trait Implementations§
impl<T, const WINDOW: usize> Freeze for RollingSum<T, WINDOW>where
T: Freeze,
impl<T, const WINDOW: usize> RefUnwindSafe for RollingSum<T, WINDOW>where
T: RefUnwindSafe,
impl<T, const WINDOW: usize> Send for RollingSum<T, WINDOW>where
T: Send,
impl<T, const WINDOW: usize> Sync for RollingSum<T, WINDOW>where
T: Sync,
impl<T, const WINDOW: usize> Unpin for RollingSum<T, WINDOW>where
T: Unpin,
impl<T, const WINDOW: usize> UnsafeUnpin for RollingSum<T, WINDOW>where
T: UnsafeUnpin,
impl<T, const WINDOW: usize> UnwindSafe for RollingSum<T, WINDOW>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