Why does cloning my custom type result in &T instead of T?
问题 use generic_array::*; // 0.12.3 use num::{Float, Zero}; // 0.2.0 #[derive(Clone, Debug)] struct Vector<T, N: ArrayLength<T>> { data: GenericArray<T, N>, } impl<T, N: ArrayLength<T>> Vector<T, N> where T: Float + Zero, { fn dot(&self, other: Self) -> T { self.data .iter() .zip(other.data.iter()) .fold(T::zero(), |acc, x| acc + *x.0 * *x.1) } fn length_sq(&self) -> T { self.dot(self.clone()) } } error[E0308]: mismatched types --> src/lib.rs:21:18 | 21 | self.dot(self.clone()) | ^^^^^^^^^^^^