title: How do I pass a vector and return a vector of strings?
body: <p>I'm trying to figure out what I need to do to pass a vector and return a vector of strings in order to solve the anagram exercise on <a href="http://exercism.io" rel="nofollow noreferrer">exercism.io</a>.</p>
  
  <p>Here is the test that I'm trying to pass:</p>
  
  <pre><code>fn test_no_matches() {
      let inputs = ["hello", "world", "zombies", "pants"];
      let outputs: Vec&lt;&amp;str&gt; = vec![];
      assert_eq!(anagrams_for("diaper", &amp;inputs), outputs);
  }
  </code></pre>
  
  <p>and here is what I have written so far:</p>
  
  <pre><code>pub fn anagrams_for&lt;'a&gt;(word: &amp;str, inp: Vec&lt;&amp;'a str&gt;) -&gt; Vec&lt;&amp;'a str&gt; {
      let mut out: Vec&lt;&amp;str&gt; = vec![];
      let ref poss = *inp[1];
      out.push(poss);
      out
  }
  </code></pre>
  
  <p>But the test fails to compile at <code>&amp;inputs</code>, giving me this error:</p>
  
  <pre class="lang-none prettyprint-override"><code>error[E0308]: mismatched types
   --&gt; src/lib.rs:4:39
    |
  4 |     assert_eq!(anagrams_for("diaper", &amp;inputs), outputs);
    |                                       ^^^^^^^
    |                                       |
    |                                       expected struct `std::vec::Vec`, found `&amp;[&amp;str; 4]`
    |                                       help: try using a conversion method: `(&amp;inputs).to_vec()`
    |
    = note: expected struct `std::vec::Vec&lt;&amp;str&gt;`
            found reference `&amp;[&amp;str; 4]`
  </code></pre>
  
  <p>I've read about references, borrowing, and lifetimes. I can honestly say that I am a bit confused about passing references around. I thought about the return vector as just a <code>Vec&lt;String&gt;</code> but I think there was an issue about the input vectors reference to a str that was causing the problems.</p>
  
  <p>If anyone could push me in a better direction that would be appreciated as I don't want to Kirk the test.</p>