Hacker News new | ask | show | jobs
by Sharlin 383 days ago
Rust has some precedence for adding convenience newtypes with overloaded operators (eg. `Wrapping<I>ยด for `I.wrapping_add(I)` etc). Such a wrapper isn't currently proposed AFAIK but there's no reason one couldn't be added in the future I believe.
2 comments

For giggles, here's one I whipped up, along with an example use: https://godbolt.org/z/Eezj35dzc
Having done unspeakable things with the C preprocessor myself, this Rust macro soup truly warms my heart <3
Oh this is simple, this is just a bit of basic expansion to generate boilerplate. The real experts can do some gnarly and amazing stuff with macros.
Wow, that's some hardcore unrolling.
Right, as long as the LLVM intrinsics are exposed you could just put that in a crate somewhere.