aboutsummaryrefslogtreecommitdiff
path: root/mingling_macros/src/func/group.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-07-21 19:16:10 +0800
committer魏曹先生 <1992414357@qq.com>2026-07-21 19:16:31 +0800
commit1803dd427416ef19918c0ec7d50093b6d45f29af (patch)
tree4caef66649536886c27e83617066b25ad6c4ac3b /mingling_macros/src/func/group.rs
parent02823638a9b9c954e13b8ae7d29bd0ae98deaf51 (diff)
feat(any): make `Grouped` trait unsafe and encapsulate `AnyOutput`
fields Declare `Grouped` as `unsafe trait` to make its soundness invariant visible. Make `AnyOutput.type_id` and `member_id` private; add public accessors and the `unsafe fn new_bare` constructor.
Diffstat (limited to 'mingling_macros/src/func/group.rs')
-rw-r--r--mingling_macros/src/func/group.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/mingling_macros/src/func/group.rs b/mingling_macros/src/func/group.rs
index b865913..edb1fe1 100644
--- a/mingling_macros/src/func/group.rs
+++ b/mingling_macros/src/func/group.rs
@@ -133,7 +133,11 @@ pub(crate) fn group_macro(input: TokenStream) -> TokenStream {
#type_use
#alias_use
- impl ::mingling::Grouped<__MinglingProgram> for #type_name {
+ /// SAFETY: This is an internal implementation of the `group!` macro,
+ /// guaranteeing that the enum value registered by the `register_type!` macro
+ /// is exactly the same as the actual return value,
+ /// which can be confirmed via the `Ident` in the `quote!` block.
+ unsafe impl ::mingling::Grouped<__MinglingProgram> for #type_name {
fn member_id() -> __MinglingProgram {
__MinglingProgram::#type_name
}