-
Notifications
You must be signed in to change notification settings - Fork 148
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
num_derive for newtypes #341
Comments
Those |
I think proc_macro is better. #[derive(One, Zero, Num, PartialEq)]
struct R64(f64); What do you think? |
I am writing a #[derive(stdops)]
#[unary_ops(Not, Neg, Deref, ...)]
#[binary_ops(Add = "Self", Add = "f64", Index = "usize")]
struct R64(f64); to specify exactly what you want to derive. It then builds on this to support ops groups: [derive(stdops)]
[numops]
[binary_ops(DivAssign = "Self")]
struct R64(f64); If you want I can commit it and maybe we can collaborate. The idea is to derive all ops in |
It looks great :) |
It works on stable rust (uses only custom derive). Yes I intended it as a separate crate because I think it is generally useful. |
As far as num-derive goes, I was only thinking of derivations for num's own traits. For more general stuff, see also derive_more. |
|
This issue was moved to rust-num/num-derive#1 |
Say I want to implement some num traits for:
Is there a macro in
num_derive
to do this? Currently FromPrimitive and ToPrimitive only work on enums.The text was updated successfully, but these errors were encountered: