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

Trait for default const values #131

Merged
merged 1 commit into from
Nov 11, 2022

Conversation

eggyal
Copy link
Contributor

@eggyal eggyal commented Sep 11, 2022

Introduces a trait defining an associated constant of the Self type. An implementation is provided for GenericArray, providing means of constructing default GenericArrays in const context.

This plugs a gap that exists even if #130 is merged, as generic type parameters cannot currently be referenced in const context (e.g. if the repetition length provided to the arr! macro comes from a type parameter).

@eggyal eggyal force-pushed the arbitrary-const-value branch 2 times, most recently from 0cff6f8 to 7a650d9 Compare September 11, 2022 12:13
@eggyal eggyal changed the title Trait for arbitrary const values Trait for default const values Sep 11, 2022
@eggyal
Copy link
Contributor Author

eggyal commented Sep 11, 2022

Perhaps, for maximum interop, this should use https://crates.io/crates/const-default ?

@novacrazy
Copy link
Collaborator

Probably would be best to use the const-default crate.

Utilises the `const-default` crate (behind a feature gate) to introduce
a trait defining an associated constant of the `Self` type.  An
implementation is provided for `GenericArray`, providing means of
constructing default `GenericArray`s in const context.

This plugs a gap that exists even after fizyk20#130 was merged, as generic type
parameters cannot currently be referenced in const context (e.g. if the
repetition length provided to the `arr!` macro comes from a type
parameter).
@eggyal
Copy link
Contributor Author

eggyal commented Nov 5, 2022

I've switched to the const-default crate as suggested, but behind a feature gate so that the dependency isn't brought in unless required.

@novacrazy novacrazy merged commit 1f50abb into fizyk20:master Nov 11, 2022
@eggyal eggyal deleted the arbitrary-const-value branch November 12, 2022 20:11
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