You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

19 lines
478 B

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