Help with copy and clone traits


Hi, I’m writing a small game to learn rust, and I’m having problems with getting a small struct out of an array slice.

The struct in question is templated and marked as deriving(Copy,Clone), but when I try to move it, I get error: cannot move out of type[physics::particle::Particle<'a, T>], a non-copy fixed-size array on this line. It contains another struct (with only f32s and again deriving(Copy,Clone)) and a borrowed non-mutable reference.

The whole function in which the error appears is a recursive building function for a bounding box hierarchy tree, taking a array slice that contains particles, and outputting the completed particle tree.

What am I doing wrong?

Another thing I tried was to replace the passing by value by calling .clone(), but then i still get an error – this time error: no method namedclonefound for typephysics::particle::Particle<'a, T>in the current scope with a hint to implement or put in scope core::clone::Clone … I also didn’t manage to make this work.

Sorry for putting up links to the whole repo, but I’ve tried several times to make a MWE for this and failed miserably :slight_smile:


It looks like the trait derivation doesn’t implement Copy for Particle<'a, T> unless T itself is Copy (which doesn’t make much sense, since Particle only contains an &T, which is Copy). I’m not sure if this is a bug or if there is a good reason for this
If you manually implement Copy and Clone, everything seems to work as expected (see last commit on


It seems derivation isn’t smart, it just checks if T implements a particular trait.


Thanks, this is exactly it :slight_smile: