Skip to content

Conversation

@GarmashAlex
Copy link
Contributor

Filled in the previously empty enum-types.adoc section with concrete documentation for advanced enum usage in Cairo. It explains how to define and use generic enums, shows how matching on generic enums works, and introduces common patterns such as Option for optional values and Result<T, E> for success/error flows. The goal is to complement the basic
enums.adoc page and give readers practical guidance on modeling data with reusable enum abstractions.

@reviewable-StarkWare
Copy link

This change is Reviewable

Copy link
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: 0 of 1 files reviewed, 6 unresolved discussions (waiting on @GarmashAlex)


docs/reference/src/components/cairo/modules/language_constructs/pages/enum-types.adoc line 21 at r1 (raw file):

        Some: T,
        None: (),
    }

Suggestion:

        Some: T,
        None,
    }

docs/reference/src/components/cairo/modules/language_constructs/pages/enum-types.adoc line 31 at r1 (raw file):

[source,cairo]
----
use option::Option;

docs/reference/src/components/cairo/modules/language_constructs/pages/enum-types.adoc line 49 at r1 (raw file):

[source,cairo]
----
    enum Pair<T, U> {

weird example.


docs/reference/src/components/cairo/modules/language_constructs/pages/enum-types.adoc line 64 at r1 (raw file):

use option::Option;

fn unwrap_or_default(x: Option<u32>, default: u32) -> u32 {

Suggestion:

fn unwrap_or_default(x: Option<u32>, default: u32) -> u32 {

docs/reference/src/components/cairo/modules/language_constructs/pages/enum-types.adoc line 68 at r1 (raw file):

        Option::Some(value) => value,
        Option::None(()) => default,
    }

Suggestion:

    match x {
        Some(value) => value,
        None(()) => default,
    }

docs/reference/src/components/cairo/modules/language_constructs/pages/enum-types.adoc line 81 at r1 (raw file):

standard patterns.

=== Option

all previous examples should not be related to options - if you specifically talk about it now.

@orizi
Copy link
Collaborator

orizi commented Dec 22, 2025

No response.

Closing.

@orizi orizi closed this Dec 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants