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