#[repr(transparent)]pub struct Hold<T>(pub T);Expand description
Zero-order hold over optional input samples.
Some(x) updates the held value, while None repeats the previous one.
This is useful for interpolation pipelines and event-driven sample streams.
Together with Downsample, this forms the scalar optional-sample pair:
Downsample creates gaps by emitting None, while Hold turns those
gaps back into a continuous stream by repeating the last present sample.
At the chunk level, Interpolator plays the analogous role for turning a
scalar stream into chunk output.
§Examples
use dsp_process::{Hold, Process};
let mut hold = Hold(5);
assert_eq!(hold.process(None), 5);
assert_eq!(hold.process(Some(7)), 7);
assert_eq!(hold.process(None), 7);Tuple Fields§
§0: TTrait Implementations§
impl<T: Copy> Copy for Hold<T>
Auto Trait Implementations§
impl<T> Freeze for Hold<T>where
T: Freeze,
impl<T> RefUnwindSafe for Hold<T>where
T: RefUnwindSafe,
impl<T> Send for Hold<T>where
T: Send,
impl<T> Sync for Hold<T>where
T: Sync,
impl<T> Unpin for Hold<T>where
T: Unpin,
impl<T> UnsafeUnpin for Hold<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Hold<T>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