1
1
use crate :: internals:: {
2
- parse_input_tokens:: ParseHelpers , Error , ErrorsCollection , ParseInputTokens , Result , Spanned ,
2
+ parse_input_tokens:: ParseHelpers , ErrorsCollection , ParseInputTokens , Result , Spanned ,
3
3
} ;
4
4
use indexmap:: { IndexMap , IndexSet } ;
5
5
use proc_macro2:: Ident ;
@@ -8,23 +8,23 @@ use std::{fmt::Debug, rc::Rc};
8
8
use syn:: { parse:: ParseStream , LitBool , LitChar , LitStr } ;
9
9
10
10
impl ParseInputTokens for bool {
11
- fn parse_value ( input : ParseStream , _: & mut ErrorsCollection ) -> Result < Self > {
11
+ fn parse_value ( input : ParseStream < ' _ > , _: & mut ErrorsCollection ) -> Result < Self > {
12
12
let literal = ParseHelpers :: syn :: < LitBool > ( input) ?;
13
13
14
14
Ok ( literal. value ( ) )
15
15
}
16
16
}
17
17
18
18
impl < T : ParseInputTokens > ParseInputTokens for Box < T > {
19
- fn parse_value ( input : ParseStream , errors : & mut ErrorsCollection ) -> Result < Self > {
19
+ fn parse_value ( input : ParseStream < ' _ > , errors : & mut ErrorsCollection ) -> Result < Self > {
20
20
let value = T :: parse_value ( input, errors) ?;
21
21
22
22
Ok ( value. into ( ) )
23
23
}
24
24
}
25
25
26
26
impl ParseInputTokens for char {
27
- fn parse_value ( input : ParseStream , _: & mut ErrorsCollection ) -> Result < Self > {
27
+ fn parse_value ( input : ParseStream < ' _ > , _: & mut ErrorsCollection ) -> Result < Self > {
28
28
let literal = ParseHelpers :: syn :: < LitChar > ( input) ?;
29
29
30
30
Ok ( literal. value ( ) )
@@ -34,14 +34,14 @@ impl ParseInputTokens for char {
34
34
impl < K : ParseInputTokens + std:: hash:: Hash + Eq , V : ParseInputTokens > ParseInputTokens
35
35
for IndexMap < K , V >
36
36
{
37
- fn parse_value ( input : ParseStream , errors : & mut ErrorsCollection ) -> Result < Self > {
38
- ParseHelpers :: map ( input, errors)
37
+ fn parse_value ( input : ParseStream < ' _ > , errors : & mut ErrorsCollection ) -> Result < Self > {
38
+ Ok ( ParseHelpers :: map ( input, errors) )
39
39
}
40
40
}
41
41
42
42
impl < T : ParseInputTokens + std:: hash:: Hash + Ord > ParseInputTokens for IndexSet < Spanned < T > > {
43
- fn parse_value ( input : ParseStream , errors : & mut ErrorsCollection ) -> Result < Self > {
44
- let sequence: Vec < Spanned < T > > = ParseHelpers :: sequence ( input, errors) ? ;
43
+ fn parse_value ( input : ParseStream < ' _ > , errors : & mut ErrorsCollection ) -> Result < Self > {
44
+ let sequence: Vec < Spanned < T > > = ParseHelpers :: sequence ( input, errors) ;
45
45
46
46
let mut set = Self :: new ( ) ;
47
47
@@ -58,15 +58,19 @@ impl<T: ParseInputTokens + std::hash::Hash + Ord> ParseInputTokens for IndexSet<
58
58
}
59
59
60
60
impl < T : ParseInputTokens > ParseInputTokens for Option < T > {
61
- fn parse_value ( input : ParseStream , errors : & mut ErrorsCollection ) -> Result < Self > {
61
+ fn parse_value ( input : ParseStream < ' _ > , errors : & mut ErrorsCollection ) -> Result < Self > {
62
62
if input. is_empty ( ) {
63
63
Ok ( None )
64
64
} else {
65
65
Ok ( Some ( T :: parse_value ( input, errors) ?) )
66
66
}
67
67
}
68
68
69
- fn parse_field ( name : & str , input : ParseStream , errors : & mut ErrorsCollection ) -> Result < Self > {
69
+ fn parse_field (
70
+ name : & str ,
71
+ input : ParseStream < ' _ > ,
72
+ errors : & mut ErrorsCollection ,
73
+ ) -> Result < Self > {
70
74
match ParseHelpers :: syn :: < Ident > ( & input. fork ( ) ) {
71
75
Ok ( key) if key == name => Ok ( Some ( ParseHelpers :: field ( name, input, errors) ?) ) ,
72
76
_ => Ok ( None ) ,
@@ -75,15 +79,15 @@ impl<T: ParseInputTokens> ParseInputTokens for Option<T> {
75
79
}
76
80
77
81
impl < T : ParseInputTokens > ParseInputTokens for Rc < T > {
78
- fn parse_value ( input : ParseStream , errors : & mut ErrorsCollection ) -> Result < Self > {
82
+ fn parse_value ( input : ParseStream < ' _ > , errors : & mut ErrorsCollection ) -> Result < Self > {
79
83
let value = T :: parse_value ( input, errors) ?;
80
84
81
85
Ok ( value. into ( ) )
82
86
}
83
87
}
84
88
85
89
impl ParseInputTokens for String {
86
- fn parse_value ( input : ParseStream , errors : & mut ErrorsCollection ) -> Result < Self > {
90
+ fn parse_value ( input : ParseStream < ' _ > , errors : & mut ErrorsCollection ) -> Result < Self > {
87
91
let literal = ParseHelpers :: syn :: < LitStr > ( input) ?;
88
92
let value = literal. value ( ) ;
89
93
@@ -96,21 +100,22 @@ impl ParseInputTokens for String {
96
100
}
97
101
98
102
impl ParseInputTokens for usize {
99
- fn parse_value ( input : ParseStream , _: & mut ErrorsCollection ) -> Result < Self > {
103
+ fn parse_value ( input : ParseStream < ' _ > , _: & mut ErrorsCollection ) -> Result < Self > {
100
104
let literal = ParseHelpers :: syn :: < syn:: LitInt > ( input) ?;
105
+ let value = literal. base10_parse :: < usize > ( ) ?;
101
106
102
- literal . base10_parse :: < usize > ( ) . map_err ( Error :: from_syn )
107
+ Ok ( value )
103
108
}
104
109
}
105
110
106
111
impl < T : ParseInputTokens > ParseInputTokens for Vec < T > {
107
- fn parse_value ( input : ParseStream , errors : & mut ErrorsCollection ) -> Result < Self > {
108
- ParseHelpers :: sequence ( input, errors)
112
+ fn parse_value ( input : ParseStream < ' _ > , errors : & mut ErrorsCollection ) -> Result < Self > {
113
+ Ok ( ParseHelpers :: sequence ( input, errors) )
109
114
}
110
115
}
111
116
112
117
impl ParseInputTokens for Version {
113
- fn parse_value ( input : ParseStream , errors : & mut ErrorsCollection ) -> Result < Self > {
118
+ fn parse_value ( input : ParseStream < ' _ > , errors : & mut ErrorsCollection ) -> Result < Self > {
114
119
let literal = ParseHelpers :: syn :: < LitStr > ( input) ?;
115
120
116
121
match Self :: parse ( & literal. value ( ) ) {
0 commit comments