title: How can we initialize a BigDecimal array in Rust?
body: <p>I wanted to have an array of BigDecimal values, as I know the size ahead of time and it is constant.</p>
  <p>I cannot figure out how it could be initialized in Rust however. This method:</p>
  <pre class="lang-rust prettyprint-override"><code>#[derive(Debug)]
  struct BigArray { values: [BigDecimal; 52] }
  fn main() {
      let mut v = BigArray { values: [BigDecimal::from_str(&quot;0&quot;); 52] };
      println!(&quot;{:?}&quot;, v);
  }
  </code></pre>
  <p>yields the following error:</p>
  <blockquote>
  <p>the trait <code>Copy</code> is not implemented for <code>BigDecimal</code></p>
  <p>note: the <code>Copy</code> trait is required because the repeated element will be copied</p>
  </blockquote>
  <p>I do want the default BigDecimal value to be cloned across the array.</p>
  <p>Is it impossible to do? Is Vec the only option?</p>
  <p><em>I can <a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2021&amp;gist=819b5774ac6d1a113f69277265cf5bb7" rel="noreferrer">turn it into a borrowed value</a> but then it is no longer a BigDecimal array, and lifetime management and dangling pointers become quite hairy.</em></p>
  <p><a href="https://play.rust-lang.org/?version=stable&amp;mode=debug&amp;edition=2021&amp;gist=ff4f3991bd02cc2ea4bf8746cba49acc" rel="noreferrer">Rust playground snippet</a>.</p>