@@ -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 ) -> String {
101
113
assert_eq ! ( expect_ident( it) , expected_name) ;
102
114
assert_eq ! ( expect_punct( it) , ':' ) ;
@@ -325,9 +337,9 @@ struct ModuleInfo {
325
337
type_ : String ,
326
338
license : String ,
327
339
name : String ,
328
- author : Option < String > ,
340
+ author : Vec < String > ,
329
341
description : Option < String > ,
330
- alias : Option < String > ,
342
+ alias : Vec < String > ,
331
343
params : Vec < ParamInfo > ,
332
344
}
333
345
@@ -367,11 +379,16 @@ impl ModuleInfo {
367
379
match key. as_str ( ) {
368
380
"type" => info. type_ = expect_ident ( it) ,
369
381
"name" => info. name = expect_string ( it) ,
370
- "author" => info. author = Some ( expect_string ( it ) ) ,
382
+ "author" => info. author = parse_item_or_list ( it , Delimiter :: Bracket , expect_string ) ,
371
383
"description" => info. description = Some ( expect_string ( it) ) ,
372
384
"license" => info. license = expect_string ( it) ,
373
- "alias" => info. alias = Some ( expect_string ( it) ) ,
374
- "alias_rtnl_link" => info. alias = Some ( format ! ( "rtnl-link-{}" , expect_string( it) ) ) ,
385
+ "alias" => info. alias = parse_item_or_list ( it, Delimiter :: Bracket , expect_string) ,
386
+ "alias_rtnl_link" => {
387
+ info. alias = parse_item_or_list ( it, Delimiter :: Bracket , expect_string)
388
+ . into_iter ( )
389
+ . map ( |x| format ! ( "rtnl-link-{}" , x) )
390
+ . collect ( )
391
+ }
375
392
"params" => info. params = parse_list ( it, Delimiter :: Brace , ParamInfo :: parse) ,
376
393
_ => panic ! (
377
394
"Unknown key \" {}\" . Valid keys are: {:?}." ,
@@ -411,10 +428,14 @@ impl ModuleInfo {
411
428
412
429
fn generate ( & self ) -> TokenStream {
413
430
let mut modinfo = ModInfoBuilder :: new ( & self . name ) ;
414
- modinfo. emit_optional ( "author" , self . author . as_deref ( ) ) ;
431
+ for author in self . author . iter ( ) {
432
+ modinfo. emit ( "author" , author) ;
433
+ }
415
434
modinfo. emit_optional ( "description" , self . description . as_deref ( ) ) ;
416
435
modinfo. emit ( "license" , & self . license ) ;
417
- modinfo. emit_optional ( "alias" , self . alias . as_deref ( ) ) ;
436
+ for alias in self . alias . iter ( ) {
437
+ modinfo. emit ( "alias" , alias) ;
438
+ }
418
439
419
440
// Built-in modules also export the `file` modinfo string
420
441
let file = std:: env:: var ( "RUST_MODFILE" )
0 commit comments