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

T::zero(), T::one(), etc should be const fn #406

Open
jgarvin opened this issue Jun 22, 2021 · 2 comments
Open

T::zero(), T::one(), etc should be const fn #406

jgarvin opened this issue Jun 22, 2021 · 2 comments

Comments

@jgarvin
Copy link

jgarvin commented Jun 22, 2021

It's pretty hard to use the num crate for writing generic const fns without this. Admittedly only useful currently with #![feature(const_fn_trait_bound)] but I don't think there is any harm to making them const fn now? Would require version bump though.

@cuviper
Copy link
Member

cuviper commented Jun 22, 2021

What would that do to types that can't be const, like BigInt?

@jgarvin
Copy link
Author

jgarvin commented Jun 22, 2021

Ah, I've only been using for abstraction over primitive types. Maybe PrimInt can have supertraits ConstOne and ConstZero? I don't know if Rust provides any way to avoid duplicating traits for every operation.

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

2 participants