using System; using System.Runtime.InteropServices; namespace gaemstone.Utility; public readonly ref struct SpanToRef where T : class { private readonly Span _span; public int Length => _span.Length; public T? this[int index] => (_span[index] != 0) ? (T)((GCHandle)_span[index]).Target! : null; internal SpanToRef(Span span) => _span = span; public void Clear() => _span.Clear(); public void CopyTo(SpanToRef dest) => _span.CopyTo(dest._span); }