aboutsummaryrefslogtreecommitdiff
path: root/mingling_pathf/src/patterns/pack.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_pathf/src/patterns/pack.rs')
-rw-r--r--mingling_pathf/src/patterns/pack.rs26
1 files changed, 16 insertions, 10 deletions
diff --git a/mingling_pathf/src/patterns/pack.rs b/mingling_pathf/src/patterns/pack.rs
index f025f7d..c80fb65 100644
--- a/mingling_pathf/src/patterns/pack.rs
+++ b/mingling_pathf/src/patterns/pack.rs
@@ -1,3 +1,7 @@
+//! The `PackPattern` matches types defined by `pack!`, `pack_err!`, `pack_structural!`, and `pack_err_structural!` macros.
+//! It extracts the registered type name (e.g., `TypeName` from `pack!(TypeName = InnerType)`).
+//! This is used to track packed type definitions for code generation or analysis.
+
use syn::Item;
use crate::pattern_analyzer::{AnalyzeItem, AnalyzePattern};
@@ -40,12 +44,13 @@ impl AnalyzePattern for PackPattern {
if let Some((_, nested)) = &item_mod.content {
for n in nested {
if let Item::Macro(m) = n
- && let Some(name) = try_extract_pack_name(m) {
- items.push(AnalyzeItem {
- module: item_mod.ident.to_string(),
- item_name: name,
- });
- }
+ && let Some(name) = try_extract_pack_name(m)
+ {
+ items.push(AnalyzeItem {
+ module: item_mod.ident.to_string(),
+ item_name: name,
+ });
+ }
}
}
}
@@ -89,10 +94,11 @@ fn try_extract_pack_name(m: &syn::ItemMacro) -> Option<String> {
// Check if `=` follows
if let Some(proc_macro2::TokenTree::Punct(p)) = iter.next()
- && p.as_char() == '=' {
- // pack!(TypeName = InnerType)
- return Some(type_name);
- }
+ && p.as_char() == '='
+ {
+ // pack!(TypeName = InnerType)
+ return Some(type_name);
+ }
// pack_err!(TypeName) — only a single ident
return Some(type_name);