title: Convert a Vec<u16> or Vec<WCHAR> to a &str
body: <p>I'm getting into Rust programming to realize a small program and I'm a little bit lost in string conversions.</p>
  
  <p>In my program, I have a vector as follows:</p>
  
  <pre><code>let mut name: Vec&lt;winnt::WCHAR&gt; = Vec::new(); 
  </code></pre>
  
  <p><code>WCHAR</code> is the same as a <code>u16</code> on my Windows machine. </p>
  
  <p>I hand over the <code>Vec&lt;u16&gt;</code> to a C function (as a pointer) which fills it with data. I then need to convert the string contained in the vector into a  <code>&amp;str</code>. However, no matter, what I try, I can not manage to get this conversion working. </p>
  
  <p>The only thing I managed to get working is to convert it to a <code>WideString</code>: </p>
  
  <pre><code> widestr = unsafe { WideCString::from_ptr_str(name.as_ptr()) };
  </code></pre>
  
  <p>But this seems to be a step into the wrong direction.</p>
  
  <p>What is the best way to convert the <code>Vec&lt;u16&gt;</code> to an <code>&amp;str</code> under the assumption that the vector holds a valid and null-terminated string.</p>