@@ -6,7 +6,6 @@ use syn::*;
6
6
mod kw {
7
7
syn:: custom_keyword!( DEBUG_FORMAT ) ;
8
8
syn:: custom_keyword!( MAX ) ;
9
- syn:: custom_keyword!( ENCODABLE ) ;
10
9
syn:: custom_keyword!( custom) ;
11
10
syn:: custom_keyword!( ORD_IMPL ) ;
12
11
}
@@ -27,7 +26,7 @@ struct Newtype(TokenStream);
27
26
28
27
impl Parse for Newtype {
29
28
fn parse ( input : ParseStream < ' _ > ) -> Result < Self > {
30
- let attrs = input. call ( Attribute :: parse_outer) ?;
29
+ let mut attrs = input. call ( Attribute :: parse_outer) ?;
31
30
let vis: Visibility = input. parse ( ) ?;
32
31
input. parse :: < Token ! [ struct ] > ( ) ?;
33
32
let name: Ident = input. parse ( ) ?;
@@ -51,6 +50,17 @@ impl Parse for Newtype {
51
50
Ok ( ( ) )
52
51
} ;
53
52
53
+ attrs. retain ( |attr| match attr. path . get_ident ( ) {
54
+ Some ( ident) => match & * ident. to_string ( ) {
55
+ "custom_encodable" => {
56
+ encodable = false ;
57
+ false
58
+ }
59
+ _ => true ,
60
+ } ,
61
+ _ => true ,
62
+ } ) ;
63
+
54
64
if body. lookahead1 ( ) . peek ( Token ! [ ..] ) {
55
65
body. parse :: < Token ! [ ..] > ( ) ?;
56
66
} else {
@@ -81,14 +91,6 @@ impl Parse for Newtype {
81
91
}
82
92
continue ;
83
93
}
84
- if body. lookahead1 ( ) . peek ( kw:: ENCODABLE ) {
85
- body. parse :: < kw:: ENCODABLE > ( ) ?;
86
- body. parse :: < Token ! [ =] > ( ) ?;
87
- body. parse :: < kw:: custom > ( ) ?;
88
- try_comma ( ) ?;
89
- encodable = false ;
90
- continue ;
91
- }
92
94
if body. lookahead1 ( ) . peek ( kw:: ORD_IMPL ) {
93
95
body. parse :: < kw:: ORD_IMPL > ( ) ?;
94
96
body. parse :: < Token ! [ =] > ( ) ?;
0 commit comments