Hi, Getting the error: the trait Clone
is not implemented for &mut T
. Any help or pointer please?
pub trait Indicator
{
type Item;
fn get_input_series(&self) -> CandleSeries;
fn get_input_series_len(&self) -> usize;
fn get_value(&mut self, index: usize) -> Option<Self::Item>;
fn get_last_value(&mut self) -> Option<Self::Item> {
let len: usize = self.get_input_series_len();
self.get_value(len - 1)
}
fn get_all_values(&mut self) -> Vec<Option<Self::Item>>;
fn calculate(&mut self, index: usize) -> Option<Self::Item>;
fn calculate_all(&mut self) -> Vec<Option<Self::Item>>;
}
#[derive(PartialOrd, PartialEq, Clone, Debug)]
pub struct EMAIndicator<'ema, T>
where T: Indicator + Clone {
indicator: &'ema mut T,
period: usize,
multiplier: f64,
calc_indicator_values: Vec<Option<f64>>,
}
error[E0277]: the trait bound `&mut T: Clone` is not satisfied
--> src/traits.rs:281:5
|
281 | indicator: &'ema mut T,
| ^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `&mut T`
|
= help: the following implementations were found:
<&T as Clone>
<&mut T as Clone>
= note: `Clone` is implemented for `&T`, but not for `&mut T`
= note: required by `clone`
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)