apt-decoder/src/amdemod.rs

26 lines
584 B
Rust
Raw Permalink Normal View History

2016-11-24 19:40:22 +01:00
pub struct SquaringAMDemodulator<'a> {
2022-02-20 20:44:49 +01:00
iterator: Box<dyn Iterator<Item = f32> + 'a>,
2016-11-24 19:40:22 +01:00
}
impl<'a> SquaringAMDemodulator<'a> {
2022-02-20 20:44:49 +01:00
pub fn from<I>(iterator1: I) -> SquaringAMDemodulator<'a>
where
I: Iterator<Item = f32> + 'a,
{
2016-11-24 19:40:22 +01:00
SquaringAMDemodulator {
iterator: Box::new(iterator1),
}
}
}
impl<'a> Iterator for SquaringAMDemodulator<'a> {
type Item = f32;
fn next(&mut self) -> Option<Self::Item> {
match self.iterator.next() {
Some(x) => Some((x * x).sqrt()),
2022-02-20 20:44:49 +01:00
None => None,
2016-11-24 19:40:22 +01:00
}
}
}