1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
/// Internal namespace.
pub( crate ) mod private
{
// #[ allow( unused_imports ) ]
// use quote::{ quote };
// #[ allow( unused_imports ) ]
// use crate::prelude::*;
// // use crate::prelude::tree_print;
//
// ///
// /// 3 parts which are result of splitting with name.
// ///
//
// #[ derive( Debug ) ]
// pub struct SplitsWithName
// {
// /// Code before name.
// pub prefix : proc_macro2::TokenStream,
// /// Name.
// pub name : proc_macro2::TokenStream,
// /// Code after name.
// pub postfix : proc_macro2::TokenStream,
// }
//
// impl quote::ToTokens for SplitsWithName
// {
// fn to_tokens( &self, tokens : &mut proc_macro2::TokenStream )
// {
// self.prefix.to_tokens( tokens );
// self.name.to_tokens( tokens );
// self.postfix.to_tokens( tokens );
// }
// }
//
// ///
// /// Trait to get name of an syntax element.
// ///
//
// pub trait SplitWithName
// {
// /// Split with name.
// fn split_item_with_name( &self ) -> Option< SplitsWithName >;
// }
//
// impl SplitWithName for syn::Item
// {
//
// fn split_item_with_name( &self ) -> Option< SplitsWithName >
// {
//
// match self
// {
// // syn::Item::Const( item ) => item.name(),
// // syn::Item::Enum( item ) => item.name(),
// // syn::Item::ExternCrate( item ) => item.name(),
// syn::Item::Fn( item ) => item.split_item_with_name(),
// // {
// // let attrs = &item.attrs;
// // let prefix = quote!{ #( #attrs )* #item.vis };
// // let name = quote!{ };
// // let postfix = quote!{ };
// // Some( SplitsWithName { prefix, name, postfix } )
// // }
// // syn::Item::ForeignMod( item ) => item.name(),
// // syn::Item::Impl( item ) => item.name(),
// // syn::Item::Macro( item ) => item.name(),
// // syn::Item::Macro2( item ) => item.name(),
// // syn::Item::Mod( item ) => item.name(),
// // syn::Item::Static( item ) => item.name(),
// // syn::Item::Struct( item ) => item.name(),
// // syn::Item::Trait( item ) => item.name(),
// // syn::Item::TraitAlias( item ) => item.name(),
// // syn::Item::Type( item ) => item.name(),
// // syn::Item::Union( item ) => item.name(),
// // syn::Item::Use( item ) => item.name(),
// // syn::Item::Verbatim( item ) => item.name(),
// _ => None,
// }
//
// }
//
// }
//
// // impl SplitWithName for syn::Path
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // let first = self.segments.first();
// // if first.is_none()
// // {
// // return "".into()
// // }
// // let first = first.unwrap();
// // first.ident.to_string()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemConst
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // self.ident.to_string()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemEnum
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // self.ident.to_string()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemExternCrate
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // self.ident.to_string()
// // }
// // }
//
// impl SplitWithName for syn::ItemFn
// {
// fn split_item_with_name( &self ) -> Option< SplitsWithName >
// {
// let attrs = &self.attrs;
// let vis = &self.vis;
// let constness = &self.sig.constness;
// let asyncness = &self.sig.asyncness;
// let unsafety = &self.sig.unsafety;
// let abi = &self.sig.abi;
// let fn_token = &self.sig.fn_token;
// let ident = &self.sig.ident;
// let generics = &self.sig.generics;
// // let paren_token = &self.sig.paren_token;
// let inputs = &self.sig.inputs;
// let variadic = &self.sig.variadic;
// let output = &self.sig.output;
// let block = &self.block;
//
// let prefix = quote!
// {
// #( #attrs )*
// #vis
// #constness
// #asyncness
// #unsafety
// #abi
// #fn_token
// };
// let name = quote!{ #ident };
// let args = if inputs.is_empty()
// {
// quote!
// {
// #variadic
// }
// }
// else
// {
// quote!
// {
// #inputs,
// #variadic
// }
// };
// let postfix = quote!
// {
// #generics
// (
// #args
// )
// #output
// #block
// };
// let result = Some( SplitsWithName { prefix, name, postfix } );
// tree_print!( result.as_ref().unwrap() );
// result
// }
// }
//
// // // impl SplitWithName for syn::ItemForeignMod
// // // {
// // // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // // {
// // // self.ident.to_string()
// // // }
// // // }
// //
// // impl SplitWithName for syn::ItemImpl
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // if self.trait_.is_none()
// // {
// // return "".into()
// // }
// // let t = self.trait_.as_ref().unwrap();
// // t.1.name()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemMacro
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // if self.ident.is_none()
// // {
// // return "".to_string()
// // }
// // let ident = self.ident.as_ref().unwrap();
// // ident.to_string()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemMacro2
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // self.ident.to_string()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemMod
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // self.ident.to_string()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemStatic
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // self.ident.to_string()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemStruct
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // self.ident.to_string()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemTrait
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // self.ident.to_string()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemTraitAlias
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // self.ident.to_string()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemType
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // self.ident.to_string()
// // }
// // }
// //
// // impl SplitWithName for syn::ItemUnion
// // {
// // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // {
// // self.ident.to_string()
// // }
// // }
// //
// // // impl SplitWithName for syn::ItemUse
// // // {
// // // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // // {
// // // self.ident.to_string()
// // // }
// // // }
// //
// // // impl SplitWithName for syn::ItemVerbatim
// // // {
// // // fn split_item_with_name( &self ) -> Option< SplitsWithName >
// // // {
// // // self.ident.to_string()
// // // }
// // // }
}
/// Exposed namespace of the module.
pub mod exposed
{
pub use super::prelude::*;
// // use super::private as i;
}
pub use exposed::*;
/// Prelude to use essentials: `use my_module::prelude::*`.
pub mod prelude
{
// // use super::private as i;
// pub use super::private::SplitWithName;
}