Why ref structs cannot be used as type arguments? : <p>C# 7.2 <a href="https://docs.microsoft.com/en-us/dotnet/csharp/reference-semantics-with-value-types" rel="noreferrer">introduced</a> <code>ref struct</code>s. However, given a <code>ref struct</code> like this:</p>

<pre><code>public ref struct Foo {
  public int Bar;
}
</code></pre>

<p>I cannot use it as a type argument:</p>

<pre><code>int i = 0;
var x = Unsafe.As&lt;int, Foo&gt;(ref i); // &lt;- Error CS0306 The type 'Foo' may not be used as a type argument.
</code></pre>

<p>I understand that ref structs can only exist on the stack, and not the heap. But what if the generic method that would use such ref structs is guaranteed to never put them on the heap, as in the example above that uses <code>System.Runtime.CompilerServices.Unsafe</code> package? Why can I not use them in those cases as type parameters?</p>
