I wanted to have an array of BigDecimal values, as I know the size ahead of time and it is constant.
I cannot figure out how it could be initialized in Rust however. This method:
#[derive(Debug)]
struct BigArray { values: [BigDecimal; 52] }
fn main() {
let mut v = BigArray { values: [BigDecimal::from_str("0"); 52] };
println!("{:?}", v);
}
yields the following error:
the trait
Copyis not implemented forBigDecimalnote: the
Copytrait is required because the repeated element will be copied
I do want the default BigDecimal value to be cloned across the array.
Is it impossible to do? Is Vec the only option?
I can turn it into a borrowed value but then it is no longer a BigDecimal array, and lifetime management and dangling pointers become quite hairy.