title: How to access a Vector of newtypes as the underlying type
body: <p>I have a newtype:</p>
  <pre><code>#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq, PartialOrd, Ord)]
  pub struct Foo(pub u32);
  </code></pre>
  <p>and a vector of them:</p>
  <pre><code>let v: Vec&lt;Foo&gt; = Vec::new();
  </code></pre>
  <p>I need a read-only reference to <code>v</code> as <code>Vec&lt;u32&gt;</code>.</p>
  <p>How can I do this without wastefully making a new vector?</p>
  <p>And the reverse?</p>
  <p>My current workaround involves creating a new vector:</p>
  <pre><code>foo_vec.iter().map(|x| x.0).collect()
  </code></pre>
  <pre><code>u32_vec.iter().map(|x| Foo(*x)).collect()
  </code></pre>
  <p>I assume that the compiler isn't clever enough to optimise these away, even with <code>#[repr(transparent)]</code>.</p>