Skip to content

const-generics for enums #7163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

const-generics for enums #7163

wants to merge 11 commits into from

Conversation

xunilrj
Copy link
Contributor

@xunilrj xunilrj commented May 7, 2025

Description

This PR is part of #6860 and allows enums to have "const generics" like the code below:

enum E<T, const N: u64> {
    Nothing: (),
    Array: [T; N]
}

impl<T, const N: u64> E<T, N> {
    pub fn len_xxx2(self) -> u64 {
        N
    }
}

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@xunilrj xunilrj changed the title const-generics for enuma const-generics for enums May 7, 2025
@xunilrj xunilrj temporarily deployed to fuel-sway-bot May 7, 2025 18:36 — with GitHub Actions Inactive
Copy link

codspeed-hq bot commented May 7, 2025

CodSpeed Performance Report

Merging #7163 will not alter performance

Comparing xunilrj/enum-const-generics (5ac0724) with master (39251b6)

Summary

✅ 22 untouched benchmarks

@xunilrj xunilrj temporarily deployed to fuel-sway-bot May 7, 2025 20:20 — with GitHub Actions Inactive
@xunilrj xunilrj temporarily deployed to fuel-sway-bot May 7, 2025 22:59 — with GitHub Actions Inactive
@xunilrj xunilrj force-pushed the xunilrj/enum-const-generics branch from e733852 to b7c5934 Compare May 8, 2025 19:05
@xunilrj xunilrj temporarily deployed to fuel-sway-bot May 8, 2025 19:05 — with GitHub Actions Inactive
@xunilrj xunilrj temporarily deployed to fuel-sway-bot May 8, 2025 19:36 — with GitHub Actions Inactive
@xunilrj xunilrj temporarily deployed to fuel-sway-bot May 8, 2025 19:55 — with GitHub Actions Inactive
@xunilrj xunilrj temporarily deployed to fuel-sway-bot May 9, 2025 23:31 — with GitHub Actions Inactive
@xunilrj xunilrj self-assigned this May 9, 2025
@xunilrj xunilrj marked this pull request as ready for review May 9, 2025 23:53
@xunilrj xunilrj requested review from a team as code owners May 9, 2025 23:53
@IGI-111 IGI-111 temporarily deployed to fuel-sway-bot May 12, 2025 08:56 — with GitHub Actions Inactive
Copy link
Contributor

@IGI-111 IGI-111 left a comment

Choose a reason for hiding this comment

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

Can we also test a single variant enum or multiple const generic parameters?

@xunilrj xunilrj force-pushed the xunilrj/enum-const-generics branch from 20a3e44 to 5ac0724 Compare May 15, 2025 16:51
@xunilrj xunilrj temporarily deployed to fuel-sway-bot May 15, 2025 16:52 — with GitHub Actions Inactive
@xunilrj
Copy link
Contributor Author

xunilrj commented May 15, 2025

Can we also test a single variant enum or multiple const generic parameters?

  • Single variant enum: Done;
  • Multiple const generic parameters: Not working on some cases. I have created an item in the umbrella issue for this case to deal with this later.

@xunilrj xunilrj mentioned this pull request May 19, 2025
17 tasks
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.

2 participants