Skip to content
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

Support const fn implementation #3

Open
ZacJW opened this issue Nov 14, 2021 · 0 comments
Open

Support const fn implementation #3

ZacJW opened this issue Nov 14, 2021 · 0 comments

Comments

@ZacJW
Copy link
Owner

ZacJW commented Nov 14, 2021

Currently associated-derive just derives an implementation for Associated, but due to a language limitation trait methods cannot be const fn, which means the user cannot use .get_associated() to initialise a const.

One proposed solution is to optionally support generating a non-trait method on the enum which can then be const fn. In order to do so, the user should be able to supply a name for it to avoid name collision, but maybe default to get_associated. The macro will have to check that only #[assoc_const] variant attributes were used as #[assoc] wouldn't always work as it allows non-const expressions.

Issue discovered by a kind Rustacean on r/rust

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

No branches or pull requests

1 participant