Anyone know what's going on here? Why am I getting
this field does not implement
Copy
use tinyvec::ArrayVec;
#[derive(Copy, Clone)]
struct Item {
num: i32
}
#[derive(Copy, Clone)]
struct Test {
nums: ArrayVec<[Item; 20]>
}
fn main() {
let mut x = Test {
nums: ArrayVec::new()
};
}
Copy
is implemented for ArrayVec
with the following constraints:
impl<A> Copy for ArrayVec<A> where
A: Array + Copy,
A::Item: Copy,
{}
In this case, A
is an [Item; 20]
, so it implements Copy
. However, [Item; 20]
does not satisfy the constraints to implement Array
.
impl<T: Default> Array for [T; 20] {
// ^^^^^^^^^^
For [Item; 20]
to be an Array
, Item
needs to implement Default
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With