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

Implement One and Zero from num-traits #113

Open
ThomasdenH opened this issue May 14, 2024 · 3 comments
Open

Implement One and Zero from num-traits #113

ThomasdenH opened this issue May 14, 2024 · 3 comments

Comments

@ThomasdenH
Copy link

ThomasdenH commented May 14, 2024

It would be useful if any Field would implement the One and Zero traits from num-traits (and perhaps even more?). One application would be the use in nalgebra, see for example the requirements to multiply two matrices there. See also this issue.

I think it would make most sense to put it behind an enabled-by-default feature. It would be possible to have a blanket implementation for Field, or alternatively an implementation could be added to the derive macro. Which would be the best way?

@tarcieri
Copy link
Contributor

What exactly are you suggesting? A blanket impl won't work because One and Zero are defined in num_traits, and blanket impls can only be defined for traits defined in the same crate.

It would probably make sense for you to just write num_traits::{Zero, One} impls for your field types.

@ThomasdenH
Copy link
Author

I meant a blanket impl for Field. That's possible since Field is defined in ff, right?

Otherwise an automatic impl included with the derive, or is that not possible?

@tarcieri
Copy link
Contributor

The only thing that would be possible from the type system's perspective is a blanket impl of Field for types which impl some combination of num-traits traits, but that probably doesn't make practical sense

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