1use synstructure::decl_derive;
2
3mod v1;
4mod v2;
5
6decl_derive!([Encode, attributes(compactly)] => v1::derive_compactly);
7
8decl_derive!([EncodeV1, attributes(compactly)] => v1::derive_compactly);
9
10decl_derive!([EncodeV2, attributes(compactly)] => v2::derive_compactly);
11
12pub(crate) fn get_unique_name(
13 bound_names: &std::collections::BTreeSet<proc_macro2::Ident>,
14 prefix: &str,
15 tries: u32,
16) -> proc_macro2::Ident {
17 for idx in 0..tries {
18 let ident =
19 proc_macro2::Ident::new(&format!("{prefix}{idx}"), proc_macro2::Span::call_site());
20 if !bound_names.contains(&ident) {
21 return ident;
22 }
23 }
24 panic!(
25 "compactly does not currently support types with more than {tries} identical field names"
26 );
27}