Deprecate MyEnum.elements.

This commit is contained in:
Christoffer Lerno
2025-05-16 16:12:37 +02:00
parent 91db6ceeda
commit b7ae5dce8b
8 changed files with 14 additions and 13 deletions

View File

@@ -6,7 +6,7 @@ import std::io;
struct EnumMap (Printable)
{
ValueType[Enum.len] values;
ValueType[Enum.values.len] values;
}
fn void EnumMap.init(&self, ValueType init_value)

View File

@@ -8,9 +8,10 @@
module std::collections::enumset{Enum};
import std::io;
alias EnumSetType @private = $typefrom(type_for_enum_elements(Enum.elements));
const ENUM_COUNT @private = Enum.values.len;
alias EnumSetType @private = $typefrom(type_for_enum_elements(ENUM_COUNT));
const IS_CHAR_ARRAY = Enum.elements > 128;
const IS_CHAR_ARRAY = ENUM_COUNT > 128;
typedef EnumSet (Printable) = EnumSetType;
fn void EnumSet.add(&self, Enum v)

View File

@@ -24,11 +24,9 @@ struct SliceRaw
macro @enum_lookup($Type, #value, value)
{
var $elements = $Type.elements;
$for var $i = 0; $i < $elements; $i++:
var $val = $Type.from_ordinal($i);
$foreach $val : $Type.values:
if ($val.#value == value) return $val;
$endfor
$endforeach
return NOT_FOUND?;
}