You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, enums are just generic sugar for some structs and a variable. However, functions are just variables with parameters, so why not allow enums to be generic?
Example:
enum Option(T: any) { Some { value: T }, None }
// desugars to
def Option(T: any) = Option::Some { value: T } | Option::None;
struct Option::Some { value: any }
struct Option::None;
All references to parameters in the struct definitions will be replaced with the type of that parameter. Example:
enum Foo(T: int) { Bar { value: T } }
// desugars to
def Foo(T: int) = Foo::Bar { value: T };
struct Foo::Bar { value: int }
The text was updated successfully, but these errors were encountered:
Right now, enums are just generic sugar for some structs and a variable. However, functions are just variables with parameters, so why not allow enums to be generic?
Example:
All references to parameters in the struct definitions will be replaced with the type of that parameter. Example:
The text was updated successfully, but these errors were encountered: