Skip to content

Static check enum as type annotation #15

@Folyd

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    langAIScript Language Syntax

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions