gix_macros/
lib.rs

1//! A crate of useful macros used in `gix` primarily.
2//!
3//! Note that within `gix-*` crates, monomorphization should never be used for convenience, but only for performance
4//! reasons. And in the latter case, manual denomophization should be considered if the trait in questions isn't called
5//! often enough or measurements indicate that `&dyn Trait` is increasing the runtime. Thus, `gix-*` crates should probably
6//! by default prefer using `&dyn` unless measurements indicate otherwise.
7use proc_macro::TokenStream;
8
9/// When applied to functions or methods, it will turn it into a wrapper that will immediately call
10/// a de-monomorphized implementation (i.e. one that uses `&dyn Trait`).
11///
12/// That way, the landing-pads for convenience will be as small as possible which then delegate to a single
13/// function or method for implementation.
14///
15/// The parameters using the following traits can be de-monomorphized:
16///
17/// * `Into`
18/// * `AsRef`
19/// * `AsMut`
20#[proc_macro_attribute]
21pub fn momo(_attrs: TokenStream, input: TokenStream) -> TokenStream {
22    momo::inner(input.into()).into()
23}
24
25mod momo;