Skip to content

Static check enum as type annotation #15

Description

@Folyd
enum Color {
    Red = "#FF0000",
    Green = "#00FF00",
    Blue = "#0000FF",
}

fn get_color(color: Color) -> str {
    match color {
        Color::Red => "red",
        Color::Green => "green",
        Color::Blue => "blue",
    }
}

get_color(Color::Red); // red

enum AnotherEnum {}

get_color(AnotherEnum); // Error: AnotherEnum is not a Color

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    langAIScript Language Syntax

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions