Oh really? If so how to fix the build error of this program:
#[derive(Debug)]
struct SA {
x: i32,
s: Vec<u8>,
}
fn fg() -> SA {
let mut a = SA {
x: 1,
s: Vec::new(),
};
a.s.push(0);
a.s.push(1);
a
}
fn main() {
let b = fg();
println!("b is: {:?}", b);
let c = [fg(); 10];
}
the build error says:
Compiling playground v0.0.1 (file:///playground)
error[E0277]: the trait bound `SA: std::marker::Copy` is not satisfied
--> src/main.rs:21:13
|
21 | let c = [fg(); 10];
| ^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `SA`
|
= note: the `Copy` trait is required because the repeated element will be copied
error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.