1
+ use jtd_codegen:: error:: Error ;
1
2
use jtd_codegen:: target:: { self , inflect, metadata} ;
2
3
use jtd_codegen:: Result ;
3
4
use lazy_static:: lazy_static;
4
5
use serde_json:: Value ;
5
6
use std:: collections:: { BTreeMap , BTreeSet } ;
6
7
use std:: io:: Write ;
7
- use jtd_codegen:: error:: Error ;
8
8
9
9
lazy_static ! {
10
10
static ref KEYWORDS : BTreeSet <String > = include_str!( "keywords" )
@@ -238,9 +238,7 @@ impl jtd_codegen::target::Target for Target {
238
238
let mut derives = vec ! [ "Serialize" , "Deserialize" ] ;
239
239
240
240
if let Some ( s) = metadata. get ( "rustCustomDerive" ) . and_then ( |v| v. as_str ( ) ) {
241
- derives. extend (
242
- s. split ( "," )
243
- ) ;
241
+ derives. extend ( s. split ( "," ) ) ;
244
242
}
245
243
246
244
state
@@ -251,29 +249,21 @@ impl jtd_codegen::target::Target for Target {
251
249
252
250
let mut custom_use = Vec :: < & str > :: new ( ) ;
253
251
if let Some ( s) = metadata. get ( "rustCustomUse" ) . and_then ( |v| v. as_str ( ) ) {
254
- custom_use. extend (
255
- s. split ( ";" )
256
- ) ;
252
+ custom_use. extend ( s. split ( ";" ) ) ;
257
253
}
258
- for cu in custom_use
259
- {
254
+ for cu in custom_use {
260
255
// custom::path::{import,export} or custom::path::single
261
256
let mut use_imports = Vec :: < & str > :: new ( ) ;
262
257
let mut path_parts = cu. split ( "::" ) . collect :: < Vec < & str > > ( ) ;
263
258
let mut last_part = path_parts. pop ( ) . unwrap ( ) ;
264
259
// If there are no path_parts or the last part was "", panic!
265
260
if path_parts. len ( ) < 1 || last_part. trim ( ) . len ( ) < 1 {
266
- return Err (
267
- Error :: Io (
268
- std:: io:: Error :: new (
269
- std:: io:: ErrorKind :: Other ,
270
- format ! ( "Invalid custom use statement: {:?}" , cu)
271
- )
272
- )
273
- ) ;
261
+ return Err ( Error :: Io ( std:: io:: Error :: new (
262
+ std:: io:: ErrorKind :: Other ,
263
+ format ! ( "Invalid custom use statement: {:?}" , cu) ,
264
+ ) ) ) ;
274
265
}
275
- if last_part. starts_with ( '{' )
276
- {
266
+ if last_part. starts_with ( '{' ) {
277
267
// Strip the first/last chars and split
278
268
last_part = & last_part[ 1 ..last_part. len ( ) - 1 ] ;
279
269
use_imports. extend ( last_part. split ( "," ) )
0 commit comments