Crate with a derive macro to simplify generic arithmetic

Hello, I have written a procedural macro crate as part of a larger project, that
make generic coding with number simpler.

In the derive macro, one write the mathematical expression with the types and the procedural macro generate the appropriate where clauses.

For example

#[arithmetic(I += (&D+&D)*f64*(&C-&C))]
impl<I, C, D> IntegralAdder<I, (C, D)> for TrapezAdder {
    fn sum(&mut self, prev_integral: &mut I, p0: &(C, D), p1: &(C, D)) {
        let x0 = &p0.0;
        let y0 = &p0.1;
        let x1 = &p1.0;
        let y1 = &p1.1;
        let dx = x1 - x0;
        let my = (y1 + y0) * 0.5;
        let di = my * dx;
        *prev_integral += di
    }
}

which expands to:

impl <I,C,D>IntegralAdder<I,(C,D)>for TrapezAdder where for< '_any> & '_any D: ::core::ops::Add< & '_any D> ,for< '_any> < & '_any D as ::core::ops::Add< & '_any D> > ::Output: ::core::ops::Mul ,for< '_any> & '_any C: ::core::ops::Sub< & '_any C> ,for< '_any> < < & '_any D as ::core::ops::Add< & '_any D> > ::Output as ::core::ops::Mul > ::Output: ::core::ops::Mul< < & '_any C as ::core::ops::Sub< & '_any C> > ::Output> ,for< '_any>I: ::core::ops::AddAssign< < < < & '_any D as ::core::ops::Add< & '_any D> > ::Output as ::core::ops::Mul > ::Output as ::core::ops::Mul< < & '_any C as ::core::ops::Sub< & '_any C> > ::Output> > ::Output>{
fn sum(&mut self,prev_integral: &mut I,p0: &(C,D),p1: &(C,D)){
let x0 = &p0.0;
let y0 = &p0.1;
let x1 = &p1.0;
let y1 = &p1.1;
let dx = x1-x0;
let my = (y1+y0)0.5;
let di = my
dx;
*prev_integral+=di
}
}

Moreover the crate contains a macro that does as type_num::op! but in more powerfull because it is a procedural macro.

I want to know if there are coders here interested in this crate, in which case I could publish it,... and I would like also a co-maintainer because I have a baby and I have not much time for side projects.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.