mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-21 17:28:00 +02:00
Added GetEnumerator
This commit is contained in:
parent
c5e1e70409
commit
b2cb8f74d3
1 changed files with 28 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
using System.Reflection;
|
||||
using System.Collections;
|
||||
|
||||
namespace System
|
||||
{
|
||||
|
@ -43,13 +44,19 @@ namespace System
|
|||
return false;
|
||||
}
|
||||
|
||||
public static readonly EnumValuesEnumerator<TEnum> GetValues<TEnum>()
|
||||
public static EnumEnumerator<TEnum> GetEnumerator<TEnum>()
|
||||
where TEnum : enum
|
||||
{
|
||||
return .();
|
||||
}
|
||||
|
||||
public static EnumValuesEnumerator<TEnum> GetValues<TEnum>()
|
||||
where TEnum : enum
|
||||
{
|
||||
return .();
|
||||
}
|
||||
|
||||
public static readonly EnumNamesEnumerator<TEnum> GetNames<TEnum>()
|
||||
public static EnumNamesEnumerator<TEnum> GetNames<TEnum>()
|
||||
where TEnum : enum
|
||||
{
|
||||
return .();
|
||||
|
@ -120,6 +127,25 @@ namespace System
|
|||
}
|
||||
}
|
||||
|
||||
public struct EnumEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<(StringView name, TEnum value)>
|
||||
where TEnum : enum
|
||||
{
|
||||
public new (StringView name, TEnum value) Current
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((.)base.Current.[Friend]mFieldData.[Friend]mName, (.)base.Current.[Friend]mFieldData.[Friend]mData);
|
||||
}
|
||||
}
|
||||
|
||||
public new Result<(StringView name, TEnum value)> GetNext() mut
|
||||
{
|
||||
if (!MoveNext())
|
||||
return .Err;
|
||||
return Current;
|
||||
}
|
||||
}
|
||||
|
||||
public struct EnumValuesEnumerator<TEnum> : EnumFieldsEnumerator<TEnum>, IEnumerator<TEnum>
|
||||
where TEnum : enum
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue