feat(collections): add implicit conversions and AddRange overloads
Added implicit conversion operators to UnsafeArray<T> and UnsafeList<T> for easier conversion to ReadOnlyUnsafeCollection<T> and Span<T>. Introduced new AddRange overloads in UnsafeList<T> for ReadOnlyUnsafeCollection<T> and pointer-based sources. Updated AssemblyVersion in all projects. Improved MemoryLeakException stack trace output and fixed a documentation comment.
This commit is contained in:
@@ -5,6 +5,7 @@ using System.Collections;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace Misaki.HighPerformance.LowLevel.Collections;
|
||||
|
||||
@@ -319,4 +320,14 @@ public unsafe struct UnsafeArray<T> : IUnsafeCollection<T>
|
||||
_buffer = null;
|
||||
_count = 0;
|
||||
}
|
||||
|
||||
public static implicit operator ReadOnlyUnsafeCollection<T>(UnsafeArray<T> array)
|
||||
{
|
||||
return array.AsReadOnly();
|
||||
}
|
||||
|
||||
public static implicit operator Span<T>(UnsafeArray<T> array)
|
||||
{
|
||||
return array.AsSpan();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user