mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-29 12:55:59 +02:00
Improved method selection for extension methods with generic 'this'
This commit is contained in:
parent
cc107ae341
commit
e64e421feb
2 changed files with 30 additions and 3 deletions
|
@ -319,6 +319,17 @@ namespace Tests
|
|||
Test.Assert((ms.mVal == 1) && (ms.mVal2 == 111) && (ms.mVal3 == 222));
|
||||
ms = .(1, 2);
|
||||
Test.Assert((ms.mVal == 1) && (ms.mVal2 == 2) && (ms.mVal3 == 222));
|
||||
|
||||
List<int32> intList = scope .();
|
||||
for (int32 i < 100)
|
||||
intList.Add(i);
|
||||
Span<int32> intSpan = intList;
|
||||
|
||||
var span = intSpan.ToRawData();
|
||||
Test.Assert(span.Length == 400);
|
||||
|
||||
span = ((int32)123).ToRawData();
|
||||
Test.Assert(span.Length == 4);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
@ -430,3 +441,12 @@ namespace Tests
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static
|
||||
{
|
||||
public static Span<uint8> ToRawData<T>(this T self) where T : struct
|
||||
{
|
||||
#unwarn
|
||||
return .((uint8*)&self, sizeof(T));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue