How to convert a boxed array into a Vec in Rust
<p>I have a boxed array of structs and I want to consume this array and insert it into a vector.</p>

<p>My current approach would be to convert the array into a vector, but the corresponding library function does not seem to work the way I expected.</p>

<pre><code>let foo = Box::new([1, 2, 3, 4]);
let bar = foo.into_vec();
</code></pre>

<p>The compiler error states </p>

<blockquote>
  <p>no method named <code>into_vec</code> found for type <code>Box&lt;[_; 4]&gt;</code> in the current scope</p>
</blockquote>

<p>I've found specifications <a href="https://doc.rust-lang.org/std/primitive.slice.html" rel="noreferrer">here</a> that look like</p>

<pre><code>fn into_vec(self: Box&lt;[T]&gt;) -&gt; Vec&lt;T&gt;
Converts self into a vector without clones or allocation.
</code></pre>

<p>... but I am not quite sure how to apply it. Any suggestions?</p>