Copy works better than Clone

This commit is contained in:
Sebastian 2020-03-17 22:41:00 +01:00
parent 9319203a22
commit 2941890adf
1 changed files with 7 additions and 7 deletions

View File

@ -3,7 +3,7 @@ use std::iter::FromIterator;
pub struct Upsampler<'a, NumType>
where
NumType: Num + Clone,
NumType: Num + Copy,
{
factor: u16,
state: u16,
@ -13,7 +13,7 @@ where
impl<'a, NumType> Upsampler<'a, NumType>
where
NumType: Num + Clone,
NumType: Num + Copy,
{
pub fn from<I>(iterator: I, factor: u16) -> Upsampler<'a, NumType>
where
@ -30,7 +30,7 @@ where
impl<'a, NumType> Iterator for Upsampler<'a, NumType>
where
NumType: Num + Clone,
NumType: Num + Copy,
{
type Item = NumType;
@ -40,13 +40,13 @@ where
}
self.state = (self.state + 1) % self.factor;
return self.sample.clone();
return self.sample;
}
}
pub struct Downsampler<'a, NumType>
where
NumType: Num + Clone + NumCast,
NumType: Num + Copy + NumCast,
{
factor: u16,
iterator: Box<dyn Iterator<Item = NumType> + 'a>,
@ -54,7 +54,7 @@ where
impl<'a, NumType> Downsampler<'a, NumType>
where
NumType: Num + Clone + NumCast,
NumType: Num + Copy + NumCast,
{
pub fn from<I>(iterator: I, factor: u16) -> Downsampler<'a, NumType>
where
@ -69,7 +69,7 @@ where
impl<'a, NumType> Iterator for Downsampler<'a, NumType>
where
NumType: Num + Clone + NumCast,
NumType: Num + Copy + NumCast,
{
type Item = NumType;