1
1
// TODO: remove me please!
2
- #![ allow( dead_code) ]
2
+ #![ allow( dead_code, unused_imports ) ]
3
3
mod defs;
4
4
mod generators;
5
5
mod linker;
@@ -55,31 +55,31 @@ enum GeneratorOutput {
55
55
}
56
56
57
57
impl GeneratorOutput {
58
- pub fn as_none ( self ) {
59
- match self {
60
- Self :: None => { }
61
- _ => panic ! ( ) ,
62
- }
58
+ pub fn as_none ( & self ) {
59
+ assert ! ( matches!( self , Self :: None ) ) ;
63
60
}
64
61
65
- pub fn as_one ( self ) -> TokenStream {
66
- match self {
67
- Self :: One ( it) => it,
68
- _ => panic ! ( ) ,
62
+ pub fn as_one ( & self ) -> & TokenStream {
63
+ if let Self :: One ( it) = self {
64
+ it
65
+ } else {
66
+ panic ! ( ) ;
69
67
}
70
68
}
71
69
72
- pub fn as_many ( self ) -> HashMap < String , TokenStream > {
73
- match self {
74
- Self :: Many ( it) => it,
75
- _ => panic ! ( ) ,
70
+ pub fn as_many ( & self ) -> & HashMap < String , TokenStream > {
71
+ if let Self :: Many ( it) = self {
72
+ it
73
+ } else {
74
+ panic ! ( ) ;
76
75
}
77
76
}
78
77
79
- pub fn as_info ( self ) -> String {
80
- match self {
81
- Self :: Info ( it) => it,
82
- _ => panic ! ( ) ,
78
+ pub fn as_info ( & self ) -> & String {
79
+ if let Self :: Info ( it) = self {
80
+ it
81
+ } else {
82
+ panic ! ( ) ;
83
83
}
84
84
}
85
85
}
@@ -186,7 +186,7 @@ fn output_dir() -> Result<String> {
186
186
187
187
#[ allow( clippy:: print_stdout) ]
188
188
fn main ( ) -> std:: result:: Result < ( ) , Box < dyn std:: error:: Error > > {
189
- let CodegenResult { schema , outputs } = files ( )
189
+ let CodegenResult { outputs , .. } = files ( )
190
190
. fold ( AstCodegen :: default ( ) , AstCodegen :: add_file)
191
191
. with ( AstGenerator )
192
192
. with ( AstKindGenerator )
@@ -199,8 +199,8 @@ fn main() -> std::result::Result<(), Box<dyn std::error::Error>> {
199
199
200
200
{
201
201
let span_path = format ! ( "{output_dir}/span.rs" ) ;
202
- let mut span_file = fs:: File :: create ( & span_path) ?;
203
- let output = outputs[ ImplGetSpanGenerator . name ( ) ] . clone ( ) . as_one ( ) ;
202
+ let mut span_file = fs:: File :: create ( span_path) ?;
203
+ let output = outputs[ ImplGetSpanGenerator . name ( ) ] . as_one ( ) ;
204
204
let span_content = pprint ( output) ;
205
205
206
206
span_file. write_all ( span_content. as_bytes ( ) ) ?;
0 commit comments