Skip to content

Commit a1ed6a1

Browse files
committed
Merge branch 'feat/gix-momo'
2 parents f658fcc + d76efdd commit a1ed6a1

32 files changed

+774
-5
lines changed

Cargo.lock

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ members = [
244244
"gix-packetline",
245245
"gix-packetline-blocking",
246246
"gix-mailmap",
247+
"gix-macros",
247248
"gix-note",
248249
"gix-negotiate",
249250
"gix-fetchhead",

gix-macros/Cargo.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
[package]
2+
name = "gix-macros"
3+
version = "0.0.0"
4+
edition = "2021"
5+
description = "Proc-macro utilities for gix"
6+
authors = [
7+
"Jiahao XU <[email protected]>",
8+
"Andre Bogus <[email protected]>",
9+
"Sebastian Thiel <[email protected]>",
10+
]
11+
repository = "https://github.com/Byron/gitoxide"
12+
license = "MIT OR Apache-2.0"
13+
include = ["src/**/*", "LICENSE-*", "CHANGELOG.md"]
14+
rust-version = "1.65"
15+
16+
[lib]
17+
proc_macro = true
18+
19+
[dependencies]
20+
syn = { version = "2.0", features = ["full", "fold"] }
21+
quote = "1.0"
22+
proc-macro2 = "1.0"
23+
24+
[dev-dependencies]
25+
trybuild = "1.0"

gix-macros/LICENSE-APACHE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE-APACHE

gix-macros/LICENSE-MIT

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../LICENSE-MIT

gix-macros/src/lib.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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.
7+
use 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]
21+
pub fn momo(_attrs: TokenStream, input: TokenStream) -> TokenStream {
22+
momo::inner(input.into()).into()
23+
}
24+
25+
mod momo;

0 commit comments

Comments
 (0)