title: Copy a ReadOnlySpan to a Span in one pass
body: <p>All guidelines seem to boil down to creating a new <code>Span</code>, initialized by an array of a given type. This involves an extra pass and an extra zeroing of the array.</p>
  
  <p>I'm wondering if there's a way to allocate some memory for a <code>Span</code> (like <code>Span -&gt; 'a[] -&gt; 'Span&lt;'a&gt;</code>), but then with a <code>ReadOnlySpan</code> as source. I currently have two approaches (<code>str</code> is a string, <code>len</code> is the string length):</p>
  
  <p>Approach 1 involves an extra pass:</p>
  
  <pre><code>let roSpan = str.AsSpan()
  let writeSpan = Span(Array.zeroCreate&lt;char&gt; len)
  roSpan.CopyTo writeSpan
  </code></pre>
  
  <p>Approach 2 has one pass too few (this turns a ReadOnlySpan into a read/write Span, dangerous stuff):</p>
  
  <pre><code>let roSpan = str.AsSpan()
  let writeSpan = MemoryMarshal.CreateSpan(&amp;MemoryMarshal.GetReference roSpan, len)
  </code></pre>
  
  <p>I've searched for both C# and F# solutions but couldn't find a good answer. One approach might be with <code>MemoryPool</code>, but that seems to be overkill for the simple "copy this into something read-/writeable".</p>
  
  <p><em><sup>tagged this both C# and F# as I don't really mind an answer in either language</sup></em></p>