Way to specify a static slice of variable length
<p>Let's say I have a function with following signature:</p>

<pre><code>fn validate(samples: &amp;[(&amp;str, &amp;[Token])])
</code></pre>

<p>Where <code>Token</code> is a custom enum.
I would like to be able to write something along those lines:</p>

<pre><code>    let samples = vec![
        ("a string", &amp;[Token::PLUS, Token::MINUS, Token::PLUS]),
        ("another string", &amp;[Token::MUL]),
    ];
    validate(&amp;samples);
</code></pre>

<p>But code like this yields mismatched types compile error:</p>

<pre><code>error: mismatched types:
expected `&amp;[(&amp;str, &amp;[Token])]`,
   found `&amp;collections::vec::Vec&lt;(&amp;str, &amp;[Token; 3])&gt;`
</code></pre>

<p>Is it possible to somehow convert the version with static length (<code>&amp;[Token; 3]</code>) to a static slice (<code>&amp;[Token]</code>)?
In other words, I would like to be able to specify a static slice in similar way I specify <code>&amp;str</code>, as some kind of "slice literal".</p>

<p>Or I am doing it completely wrong?</p>

<p>EDIT:
In short, I would like to find a syntax that creates an array with static lifetime (or at least a lifetime that is as long as the <code>samples</code> vector's one), and returns slice of it.</p>

<p>Something similar to how strings work, where just typing "a string" gives me reference of type <code>&amp;'static str</code>.</p>

<p>EDIT2:
@Pablo's answer provides pretty good solution to my particular problem, although it is not exactly what I have meant at first.</p>

<p>I guess that the exact thing I have in mind might not be possible, so I will just accept that one for now, unless something more in lines of my initial idea come around.</p>