mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Actually, allow Spans to be created from null Arrays
This commit is contained in:
parent
607cca1431
commit
36c72e794e
1 changed files with 17 additions and 3 deletions
|
@ -16,18 +16,35 @@ namespace System
|
|||
|
||||
public this(T[] array)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
this = default;
|
||||
return;
|
||||
}
|
||||
mPtr = &array.[Friend]GetRef(0);
|
||||
mLength = array.[Friend]mLength;
|
||||
}
|
||||
|
||||
public this(T[] array, int index)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
Debug.Assert(index == 0);
|
||||
this = default;
|
||||
return;
|
||||
}
|
||||
mPtr = &array[index];
|
||||
mLength = array.[Friend]mLength - index;
|
||||
}
|
||||
|
||||
public this(T[] array, int index, int length)
|
||||
{
|
||||
if (array == null)
|
||||
{
|
||||
Debug.Assert(index == 0 && length == 0);
|
||||
this = default;
|
||||
return;
|
||||
}
|
||||
if (length == 0)
|
||||
mPtr = null;
|
||||
else
|
||||
|
@ -48,9 +65,6 @@ namespace System
|
|||
|
||||
public static implicit operator Span<T> (T[] array)
|
||||
{
|
||||
if (array == null)
|
||||
return default;
|
||||
|
||||
return Span<T>(array);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue