All Projects → llogiq → Momo

llogiq / Momo

Licence: apache-2.0
A Rust proc_macro_attribute to outline conversions from generic functions

Programming Languages

rust
11053 projects

momo

Keep your compile time during MOnoMOrphization

This is a proc_macro crate to help keeping the code footprint of generic methods in check. Often, generics are used in libraries to improve ergonomics. However, this has a cost in compile time and binary size. Optimally, one creates a small shell function that does the generic conversions and then calls an inner function, but that makes the code less readable.

Add a #[momo] annotation from this crate to split your function into an outer conversion and a private inner function. In return, you get some compile time for a tiny bit of runtime (if at all) – without impairing readability.

For now, the only place where we can put the #[momo] annotations is on plain functions.

This new updated version usesi D. Tolnay's watt runtime to speed up the compile time, which was negatively affected with proc macro baggage. Rebuilding the wasm can be done with the commands:

cd wasm
cargo build --release --target wasm32-unknown-unknown
cp wasm/target/wasm32-unknown-unknown/release/momo.wasm ../src

You might need to add the wasm32-unknown-unknown target to your Rust toolchain.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].