title: How can I create a Memory<T> from a Span<T>?
body: <p>I'm trying to overload a parsing method to use a <code>ReadOnlySpan&lt;char&gt;</code> parameter in addition to the <code>string</code> version. The problem is that the implementation uses a <code>Dictionary&lt;string, T&gt;</code> for the parsing logic.</p>
  
  <p>I tried switching it to a <code>Dictionary&lt;ReadOnlySpan&lt;char&gt;, T&gt;</code> but of course that didn't work as <code>ReadOnlySpan&lt;char&gt;</code> isn't allowed as a generic parameter since it's a stack only object. I then switched it to using <code>ReadOnlyMemory&lt;char&gt;</code> which is allowed. I then implemented a basic <code>Ordinal</code> comparer but am now having troubles creating a <code>ReadOnlyMemory&lt;char&gt;</code> from the <code>ReadOnlySpan&lt;char&gt;</code> parameter. Is this possible?</p>
  
  <p><strong>Update</strong></p>
  
  <p>It seems that this is not possible. In order to support the scenario I've posted above I will change the dictionary to have an int key which is the hashcode of the <code>ReadOnlySpan&lt;char&gt;</code> and make the value a list with the string embedded in the element and manually have to resolve hash code collisions.</p>