MaybeUninit<T> is only Clone if T is Copy, because the only possible implementation of Clone for MaybeUninit is to just copy all the bytes. It cannot call clone() on T because it might be uninitialized.
In your example, TestStruct contains a Box: cloning a MaybeUninit<TestStruct> safely is impossible, because if the box is initialized then just doing a bytewise copy means you have two boxes pointing at the same allocation (so it's not possible to just copy it), and if the box isn't initialized then trying to clone it will access uninitialized memory (so it's not possible to call clone either).
let mut buffer: Vec<TestStruct> = Vec::with_capacity(16);
let mut src: Vec<TestStruct> = Vec::with_capacity(4);
for i in 0..4 {
src.push(TestStruct {
data: i,
key: i,
value: vec![i + 1; i + 1].into_boxed_slice(),
});
}
buffer.extend_from_slice(&src);
for i in 0..4 {
println!("{:?}", buffer[i]);
}
This is the same except it compiles, and it'll actually drop the first 4 items so you don't leak memory.