<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="struct Vector3&lt;S&gt;(S, S, S);

// passes type checking
fn into_vec3_arg&lt;S&gt;([x, y, z]: [S, ..3]) -&gt; Vector3&lt;S&gt; {
    Vector3(x, y, z)
}

fn into_vec3_let&lt;S&gt;(v: [S, ..3]) -&gt; Vector3&lt;S&gt; {
    let [x, y, z] = v; // error: use of moved value: `v[..]`
    Vector3(x, y, z)
}

fn into_vec3_match&lt;S&gt;(v: [S, ..3]) -&gt; Vector3&lt;S&gt; {
    match v {
        // error: use of moved value: `v[..]`
        [x, y, z] =&gt; Vector3(x, y, z),
    }
}"><pre class="notranslate"><span class="pl-k">struct</span> <span class="pl-smi">Vector3</span><span class="pl-kos">&lt;</span><span class="pl-smi">S</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-smi">S</span><span class="pl-kos">,</span> <span class="pl-smi">S</span><span class="pl-kos">,</span> <span class="pl-smi">S</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-c">// passes type checking</span>
<span class="pl-k">fn</span> <span class="pl-en">into_vec3_arg</span><span class="pl-kos">&lt;</span><span class="pl-smi">S</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-kos">[</span>x<span class="pl-kos">,</span> y<span class="pl-kos">,</span> z<span class="pl-kos">]</span><span class="pl-kos">:</span> <span class="pl-kos">[</span><span class="pl-smi">S</span><span class="pl-kos"></span><span class="pl-kos">,</span> ..<span class="pl-c1">3</span><span class="pl-kos">]</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Vector3</span><span class="pl-kos">&lt;</span><span class="pl-smi">S</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-v">Vector3</span><span class="pl-kos">(</span>x<span class="pl-kos">,</span> y<span class="pl-kos">,</span> z<span class="pl-kos">)</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">into_vec3_let</span><span class="pl-kos">&lt;</span><span class="pl-smi">S</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">v</span><span class="pl-kos">:</span> <span class="pl-kos">[</span><span class="pl-smi">S</span><span class="pl-kos"></span><span class="pl-kos">,</span> ..<span class="pl-c1">3</span><span class="pl-kos">]</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Vector3</span><span class="pl-kos">&lt;</span><span class="pl-smi">S</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">let</span> <span class="pl-kos">[</span>x<span class="pl-kos">,</span> y<span class="pl-kos">,</span> z<span class="pl-kos">]</span> = v<span class="pl-kos">;</span> <span class="pl-c">// error: use of moved value: `v[..]`</span>
    <span class="pl-v">Vector3</span><span class="pl-kos">(</span>x<span class="pl-kos">,</span> y<span class="pl-kos">,</span> z<span class="pl-kos">)</span>
<span class="pl-kos">}</span>

<span class="pl-k">fn</span> <span class="pl-en">into_vec3_match</span><span class="pl-kos">&lt;</span><span class="pl-smi">S</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">v</span><span class="pl-kos">:</span> <span class="pl-kos">[</span><span class="pl-smi">S</span><span class="pl-kos"></span><span class="pl-kos">,</span> ..<span class="pl-c1">3</span><span class="pl-kos">]</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Vector3</span><span class="pl-kos">&lt;</span><span class="pl-smi">S</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-k">match</span> v <span class="pl-kos">{</span>
        <span class="pl-c">// error: use of moved value: `v[..]`</span>
        <span class="pl-kos">[</span>x<span class="pl-kos">,</span> y<span class="pl-kos">,</span> z<span class="pl-kos">]</span> =&gt; <span class="pl-v">Vector3</span><span class="pl-kos">(</span>x<span class="pl-kos">,</span> y<span class="pl-kos">,</span> z<span class="pl-kos">)</span><span class="pl-kos">,</span>
    <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><a href="http://is.gd/bc1U2v" rel="nofollow">http://is.gd/bc1U2v</a></p>
<p dir="auto">Note that it is impossible to work around this using transmute, because:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="struct Vector3&lt;S&gt;(S, S, S);

fn into_vec3_transmute&lt;S&gt;(v: [S, ..3]) -&gt; Vector3&lt;S&gt; {
    // error: cannot transmute from a type that contains type parameters
    unsafe { mem::transmute(v) }
}"><pre class="notranslate"><span class="pl-k">struct</span> <span class="pl-smi">Vector3</span><span class="pl-kos">&lt;</span><span class="pl-smi">S</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-smi">S</span><span class="pl-kos">,</span> <span class="pl-smi">S</span><span class="pl-kos">,</span> <span class="pl-smi">S</span><span class="pl-kos">)</span><span class="pl-kos">;</span>

<span class="pl-k">fn</span> <span class="pl-en">into_vec3_transmute</span><span class="pl-kos">&lt;</span><span class="pl-smi">S</span><span class="pl-kos">&gt;</span><span class="pl-kos">(</span><span class="pl-s1">v</span><span class="pl-kos">:</span> <span class="pl-kos">[</span><span class="pl-smi">S</span><span class="pl-kos"></span><span class="pl-kos">,</span> ..<span class="pl-c1">3</span><span class="pl-kos">]</span><span class="pl-kos">)</span> -&gt; <span class="pl-smi">Vector3</span><span class="pl-kos">&lt;</span><span class="pl-smi">S</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-c">// error: cannot transmute from a type that contains type parameters</span>
    <span class="pl-k">unsafe</span> <span class="pl-kos">{</span> mem<span class="pl-kos">::</span><span class="pl-en">transmute</span><span class="pl-kos">(</span>v<span class="pl-kos">)</span> <span class="pl-kos">}</span>
<span class="pl-kos">}</span></pre></div>
<p dir="auto"><a href="http://is.gd/BeSWOs" rel="nofollow">http://is.gd/BeSWOs</a></p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let arr = [Box::new(1), Box::new(2), Box::new(3)];
let [a, b, c] = arr;"><pre class="notranslate"><span class="pl-k">let</span> arr = <span class="pl-kos">[</span><span class="pl-smi">Box</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-smi">Box</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-c1">2</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-smi">Box</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-c1">3</span><span class="pl-kos">)</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-kos">[</span>a<span class="pl-kos">,</span> b<span class="pl-kos">,</span> c<span class="pl-kos">]</span> = arr<span class="pl-kos">;</span></pre></div>
<p dir="auto">fails with</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&lt;anon&gt;:5:13: 5:14 error: use of moved value: `arr[..]` [E0382]
&lt;anon&gt;:5     let [a, b, c] = arr;
                     ^
&lt;anon&gt;:5:10: 5:11 note: `arr[..]` moved here because it has type `Box&lt;i32&gt;`, which is moved by default
&lt;anon&gt;:5     let [a, b, c] = arr;
                  ^
&lt;anon&gt;:5:10: 5:11 help: use `ref` to override"><pre class="notranslate"><code class="notranslate">&lt;anon&gt;:5:13: 5:14 error: use of moved value: `arr[..]` [E0382]
&lt;anon&gt;:5     let [a, b, c] = arr;
                     ^
&lt;anon&gt;:5:10: 5:11 note: `arr[..]` moved here because it has type `Box&lt;i32&gt;`, which is moved by default
&lt;anon&gt;:5     let [a, b, c] = arr;
                  ^
&lt;anon&gt;:5:10: 5:11 help: use `ref` to override
</code></pre></div>
<p dir="auto">while the following work fine:</p>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="let arr = [Box::new(1)];
let [a] = arr;"><pre class="notranslate"><span class="pl-k">let</span> arr = <span class="pl-kos">[</span><span class="pl-smi">Box</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-kos">[</span>a<span class="pl-kos">]</span> = arr<span class="pl-kos">;</span></pre></div>
<div class="highlight highlight-source-rust notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
enum Dummy&lt;T&gt; {
    Val([T; 2]),
}
let arr = [Box::new(1), Box::new(2)];
let Dummy::Val([a, b]) = Dummy::Val(arr);"><pre class="notranslate"><span class="pl-k">enum</span> <span class="pl-smi">Dummy</span><span class="pl-kos">&lt;</span><span class="pl-smi">T</span><span class="pl-kos">&gt;</span> <span class="pl-kos">{</span>
    <span class="pl-v">Val</span><span class="pl-kos">(</span><span class="pl-kos">[</span><span class="pl-smi">T</span><span class="pl-kos">;</span> <span class="pl-c1">2</span><span class="pl-kos">]</span><span class="pl-kos">)</span><span class="pl-kos">,</span>
<span class="pl-kos">}</span>
<span class="pl-k">let</span> arr = <span class="pl-kos">[</span><span class="pl-smi">Box</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-c1">1</span><span class="pl-kos">)</span><span class="pl-kos">,</span> <span class="pl-smi">Box</span><span class="pl-kos">::</span><span class="pl-en">new</span><span class="pl-kos">(</span><span class="pl-c1">2</span><span class="pl-kos">)</span><span class="pl-kos">]</span><span class="pl-kos">;</span>
<span class="pl-k">let</span> <span class="pl-smi">Dummy</span><span class="pl-kos">::</span><span class="pl-v">Val</span><span class="pl-kos">(</span><span class="pl-kos">[</span>a<span class="pl-kos">,</span> b<span class="pl-kos">]</span><span class="pl-kos">)</span> = <span class="pl-smi">Dummy</span><span class="pl-kos">::</span><span class="pl-v">Val</span><span class="pl-kos">(</span>arr<span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>