Prefer clone_from over assign

This commit is contained in:
2021-07-15 17:25:30 +02:00
parent e4ea5b081b
commit e25ee9c74a
6 changed files with 38 additions and 35 deletions

View File

@@ -7,16 +7,22 @@ use sbp::Float;
#[cfg(feature = "sparse")]
pub mod sparse;
#[derive(Clone, Debug)]
#[derive(Debug)]
pub struct Field(pub(crate) Array3<Float>);
impl Clone for Field {
fn clone(&self) -> Self {
Self(self.0.clone())
}
fn clone_from(&mut self, source: &Self) {
self.0.clone_from(&source.0)
}
}
impl integrate::Integrable for Field {
type State = Field;
type Diff = Field;
fn assign(s: &mut Self::State, o: &Self::State) {
s.0.assign(&o.0);
}
fn scaled_add(s: &mut Self::State, o: &Self::Diff, scale: Float) {
s.0.scaled_add(scale, &o.0);
}