@@ -97,6 +97,18 @@ fn parse_list<T>(
97
97
vec
98
98
}
99
99
100
+ fn parse_item_or_list < T > (
101
+ it : & mut Cursor < ' _ > ,
102
+ delim : Delimiter ,
103
+ f : impl Fn ( & mut Cursor < ' _ > ) -> T ,
104
+ ) -> Vec < T > {
105
+ if it. group ( delim) . is_some ( ) {
106
+ parse_list ( it, delim, f)
107
+ } else {
108
+ vec ! [ f( it) ]
109
+ }
110
+ }
111
+
100
112
fn get_literal ( it : & mut Cursor < ' _ > , expected_name : & str ) -> Literal {
101
113
assert_eq ! ( expect_ident( it) , expected_name) ;
102
114
assert_eq ! ( expect_punct( it) , ':' ) ;
@@ -316,9 +328,9 @@ struct ModuleInfo {
316
328
type_ : String ,
317
329
license : String ,
318
330
name : String ,
319
- author : Option < String > ,
331
+ author : Vec < String > ,
320
332
description : Option < String > ,
321
- alias : Option < String > ,
333
+ alias : Vec < String > ,
322
334
params : Vec < ParamInfo > ,
323
335
}
324
336
@@ -358,11 +370,16 @@ impl ModuleInfo {
358
370
match key. as_str ( ) {
359
371
"type" => info. type_ = expect_ident ( it) ,
360
372
"name" => info. name = expect_string ( it) ,
361
- "author" => info. author = Some ( expect_string ( it ) ) ,
373
+ "author" => info. author = parse_item_or_list ( it , Delimiter :: Bracket , expect_string ) ,
362
374
"description" => info. description = Some ( expect_string ( it) ) ,
363
375
"license" => info. license = expect_string ( it) ,
364
- "alias" => info. alias = Some ( expect_string ( it) ) ,
365
- "alias_rtnl_link" => info. alias = Some ( format ! ( "rtnl-link-{}" , expect_string( it) ) ) ,
376
+ "alias" => info. alias = parse_item_or_list ( it, Delimiter :: Bracket , expect_string) ,
377
+ "alias_rtnl_link" => {
378
+ info. alias = parse_item_or_list ( it, Delimiter :: Bracket , expect_string)
379
+ . into_iter ( )
380
+ . map ( |x| format ! ( "rtnl-link-{}" , x) )
381
+ . collect ( )
382
+ }
366
383
"params" => info. params = parse_list ( it, Delimiter :: Brace , ParamInfo :: parse) ,
367
384
_ => panic ! (
368
385
"Unknown key \" {}\" . Valid keys are: {:?}." ,
@@ -402,10 +419,14 @@ impl ModuleInfo {
402
419
403
420
fn generate ( & self ) -> TokenStream {
404
421
let mut modinfo = ModInfoBuilder :: new ( & self . name ) ;
405
- modinfo. emit_optional ( "author" , self . author . as_deref ( ) ) ;
422
+ for author in self . author . iter ( ) {
423
+ modinfo. emit ( "author" , author) ;
424
+ }
406
425
modinfo. emit_optional ( "description" , self . description . as_deref ( ) ) ;
407
426
modinfo. emit ( "license" , & self . license ) ;
408
- modinfo. emit_optional ( "alias" , self . alias . as_deref ( ) ) ;
427
+ for alias in self . alias . iter ( ) {
428
+ modinfo. emit ( "alias" , alias) ;
429
+ }
409
430
410
431
// Built-in modules also export the `file` modinfo string
411
432
let file = std:: env:: var ( "RUST_MODFILE" )
0 commit comments