-
Notifications
You must be signed in to change notification settings - Fork 26
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 #1
Comments
Those |
From @termoshtt on October 27, 2017 6:53 I think proc_macro is better. #[derive(One, Zero, Num, PartialEq)]
struct R64(f64); What do you think? |
From @gnzlbg on October 27, 2017 7:5 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 |
From @termoshtt on October 27, 2017 7:15 It looks great :) |
From @gnzlbg on October 27, 2017 7:19 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. |
From @gnzlbg on October 27, 2017 8:7
|
From @gnzlbg on October 26, 2017 9:18
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.Copied from original issue: rust-num/num#341
The text was updated successfully, but these errors were encountered: