@@ -439,44 +439,49 @@ impl AllTypes {
439
439
sections
440
440
}
441
441
442
- fn print ( & self , f : & mut String ) {
443
- fn print_entries ( f : & mut String , e : & FxIndexSet < ItemEntry > , kind : ItemSection ) {
444
- if !e. is_empty ( ) {
442
+ fn print ( & self ) -> impl fmt:: Display {
443
+ fn print_entries ( e : & FxIndexSet < ItemEntry > , kind : ItemSection ) -> impl fmt:: Display {
444
+ fmt:: from_fn ( move |f| {
445
+ if e. is_empty ( ) {
446
+ return Ok ( ( ) ) ;
447
+ }
448
+
445
449
let mut e: Vec < & ItemEntry > = e. iter ( ) . collect ( ) ;
446
450
e. sort ( ) ;
447
- write_str (
451
+ write ! (
448
452
f,
449
- format_args ! (
450
- "<h3 id=\" {id}\" >{title}</h3><ul class=\" all-items\" >" ,
451
- id = kind. id( ) ,
452
- title = kind. name( ) ,
453
- ) ,
454
- ) ;
453
+ "<h3 id=\" {id}\" >{title}</h3><ul class=\" all-items\" >" ,
454
+ id = kind. id( ) ,
455
+ title = kind. name( ) ,
456
+ ) ?;
455
457
456
458
for s in e. iter ( ) {
457
- write_str ( f, format_args ! ( "<li>{}</li>" , s. print( ) ) ) ;
459
+ write ! ( f, "<li>{}</li>" , s. print( ) ) ? ;
458
460
}
459
461
460
- f. push_str ( "</ul>" ) ;
461
- }
462
+ f. write_str ( "</ul>" )
463
+ } )
462
464
}
463
465
464
- f. push_str ( "<h1>List of all items</h1>" ) ;
465
- // Note: print_entries does not escape the title, because we know the current set of titles
466
- // doesn't require escaping.
467
- print_entries ( f, & self . structs , ItemSection :: Structs ) ;
468
- print_entries ( f, & self . enums , ItemSection :: Enums ) ;
469
- print_entries ( f, & self . unions , ItemSection :: Unions ) ;
470
- print_entries ( f, & self . primitives , ItemSection :: PrimitiveTypes ) ;
471
- print_entries ( f, & self . traits , ItemSection :: Traits ) ;
472
- print_entries ( f, & self . macros , ItemSection :: Macros ) ;
473
- print_entries ( f, & self . attribute_macros , ItemSection :: AttributeMacros ) ;
474
- print_entries ( f, & self . derive_macros , ItemSection :: DeriveMacros ) ;
475
- print_entries ( f, & self . functions , ItemSection :: Functions ) ;
476
- print_entries ( f, & self . type_aliases , ItemSection :: TypeAliases ) ;
477
- print_entries ( f, & self . trait_aliases , ItemSection :: TraitAliases ) ;
478
- print_entries ( f, & self . statics , ItemSection :: Statics ) ;
479
- print_entries ( f, & self . constants , ItemSection :: Constants ) ;
466
+ fmt:: from_fn ( |f| {
467
+ f. write_str ( "<h1>List of all items</h1>" ) ?;
468
+ // Note: print_entries does not escape the title, because we know the current set of titles
469
+ // doesn't require escaping.
470
+ print_entries ( & self . structs , ItemSection :: Structs ) . fmt ( f) ?;
471
+ print_entries ( & self . enums , ItemSection :: Enums ) . fmt ( f) ?;
472
+ print_entries ( & self . unions , ItemSection :: Unions ) . fmt ( f) ?;
473
+ print_entries ( & self . primitives , ItemSection :: PrimitiveTypes ) . fmt ( f) ?;
474
+ print_entries ( & self . traits , ItemSection :: Traits ) . fmt ( f) ?;
475
+ print_entries ( & self . macros , ItemSection :: Macros ) . fmt ( f) ?;
476
+ print_entries ( & self . attribute_macros , ItemSection :: AttributeMacros ) . fmt ( f) ?;
477
+ print_entries ( & self . derive_macros , ItemSection :: DeriveMacros ) . fmt ( f) ?;
478
+ print_entries ( & self . functions , ItemSection :: Functions ) . fmt ( f) ?;
479
+ print_entries ( & self . type_aliases , ItemSection :: TypeAliases ) . fmt ( f) ?;
480
+ print_entries ( & self . trait_aliases , ItemSection :: TraitAliases ) . fmt ( f) ?;
481
+ print_entries ( & self . statics , ItemSection :: Statics ) . fmt ( f) ?;
482
+ print_entries ( & self . constants , ItemSection :: Constants ) . fmt ( f) ?;
483
+ Ok ( ( ) )
484
+ } )
480
485
}
481
486
}
482
487
0 commit comments