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
static OPTIONS_TYPE: = ;
// pub fn parse_size(lit: &Option<Lit>) -> Option<isize> {
// if let Some(len) = lit {
// match len {
// Lit::Int(l) => {
// let res = l.base10_parse::<isize>();
// if let Ok(sz) = res {
// Some(sz)
// } else {
// None
// }
// },
// _ => {
// None
// }
// }
// } else { None }
// }
// pub fn parse_type_as_string(ty: &syn::Type, add_surffix: bool) -> String {
// if let syn::Type::Path(p) = ty {
// // let paths = p.path.segments.iter().map(|v| v.ident.to_string()).collect::<Vec<String>>();
// // return paths.join("::");
// let idents_of_path =
// p.path
// .segments
// .iter()
// .into_iter()
// .fold(String::new(), |mut acc, v| {
// acc.push_str(&v.ident.to_string());
// if add_surffix {
// acc.push('|');
// }
// acc
// });
// return idents_of_path;
// }
// "".to_string()
// }
// pub fn parse_types(paths: &mut Vec<&syn::Type>) {
// if let syn::Type::Path(p) = paths.last().unwrap() {
// let idents_of_path =
// p.path
// .segments
// .iter()
// .into_iter()
// .fold(String::new(), |mut acc, v| {
// acc.push_str(&v.ident.to_string());
// acc.push('|');
// acc
// });
// if is_option(&idents_of_path.as_str()) {
// // count += 1;
// if let Some(p) = p.path.segments.first() {
// if let syn::PathArguments::AngleBracketed(ref params) = p.arguments {
// if let syn::GenericArgument::Type(ref ty) = params.args.first().unwrap() {
// paths.push(ty);
// parse_types(paths);
// // count = find_option(count, ty);
// }
// }
// }
// }
// }
// // count
// }