#lower #lower-macros #wont

macro lower-macros

desugar math where the compiler wont

10 releases

0.2.8 Mar 12, 2025
0.2.7 Mar 12, 2025
0.2.2 Feb 3, 2025
0.1.2 Feb 3, 2025
0.1.0 Jan 27, 2025

#6 in #lower

Download history 79/week @ 2025-01-23 308/week @ 2025-01-30 34/week @ 2025-02-06 29/week @ 2025-02-13 1/week @ 2025-02-20 3/week @ 2025-02-27 541/week @ 2025-03-06 231/week @ 2025-03-13 5/week @ 2025-03-20

678 downloads per month
Used in lower

MIT license

20KB
511 lines

a lil macro crate.

provides a handy macro for converting a + b to a.add(b) for when you cant easily overload the Add trait.


lower

lowers expressions to their "desugared" form.

e.g

a * b + c => (a.mul(b)).add(c)

note that it is extremely pervasive, so

lower::math! { fn main() -> u8 {
    const X: u8 = 31 * 2;
    return 2 * X + 2;
} }

expands to

fn main() -> u8 {
    const X: u8 = 31.mul(2);
    return (2.mul(X)).add(2);
}

it should work for most expressions.

why

well, you see, i made a crate for arrays. then, i added add/mul/…, and got annoyed when i had to call them manually. now, you can do amazing things such as lower::math! { 2 * ([5, 2] + 5) }.

Dependencies

~195–630KB
~15K SLoC