feat(core): Add SignalAbs trait for numeric signals

This commit is contained in:
Anand Balakrishnan 2023-04-04 11:55:48 -07:00
parent 55b7cdd075
commit 6e41380262
No known key found for this signature in database
5 changed files with 72 additions and 23 deletions

View file

@ -109,11 +109,11 @@ where
Some(return_points)
}
pub fn apply1<T, F>(signal: &Signal<T>, op: F) -> Signal<T>
pub fn apply1<T, U, F>(signal: &Signal<T>, op: F) -> Signal<U>
where
T: Copy,
F: Fn(T) -> T,
Signal<T>: std::iter::FromIterator<(Duration, T)>,
F: Fn(T) -> U,
Signal<U>: std::iter::FromIterator<(Duration, U)>,
{
signal.iter().map(|(t, v)| (*t, op(*v))).collect()
}