From 11f32d55a79853ae764d2cf7c07e7174ccb0c239 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Thu, 7 May 2026 13:21:54 +0800 Subject: Add static accessor to gen_program! macro output --- CHANGELOG.md | 17 +++++++++++++++++ mingling_macros/src/lib.rs | 6 ++++++ 2 files changed, 23 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d2e761..23ceef5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelogs +### Release 0.1.8 + +#### Fixes: +None + +#### Optimizings: +None + +#### Features: + +1. **\[macros\]** The `gen_program!()` macro now generates `pub fn this() -> &'static Program<#name>` for the generated program type, providing convenient static accessors. + +#### **BREAKING CHANGES**: +None + +--- + ### Release 0.1.7 #### Fixes: diff --git a/mingling_macros/src/lib.rs b/mingling_macros/src/lib.rs index 818cda6..6d38889 100644 --- a/mingling_macros/src/lib.rs +++ b/mingling_macros/src/lib.rs @@ -1220,9 +1220,15 @@ pub fn program_final_gen(input: TokenStream) -> TokenStream { } impl #name { + /// Creates a new `Program<#name>` instance with default configuration. pub fn new() -> ::mingling::Program<#name> { ::mingling::Program::new() } + + /// Returns a static reference to the global `Program<#name>` singleton. + pub fn this() -> &'static ::mingling::Program<#name> { + &::mingling::this::<#name>() + } } }; -- cgit