1
1
use std:: ffi:: OsStr ;
2
+ use std:: fmt;
2
3
use std:: fs:: { self , File } ;
3
4
use std:: io:: prelude:: * ;
4
5
use std:: io:: { self , BufReader } ;
@@ -563,7 +564,7 @@ if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};
563
564
}
564
565
565
566
impl Implementor {
566
- fn to_js_string ( & self ) -> String {
567
+ fn to_js_string ( & self ) -> impl fmt :: Display + ' _ {
567
568
fn single_quote_string ( s : & str ) -> String {
568
569
let mut result = String :: with_capacity ( s. len ( ) + 2 ) ;
569
570
result. push_str ( "'" ) ;
@@ -577,16 +578,21 @@ if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};
577
578
result. push_str ( "'" ) ;
578
579
result
579
580
}
580
- let text_esc = single_quote_string ( & self . text ) ;
581
- if self . synthetic {
582
- let types = self . types . iter ( ) . map ( |type_| single_quote_string ( type_) ) . join ( "," ) ;
583
- // use `1` to represent a synthetic, because it's fewer bytes than `true`
584
- format ! ( "[{text_esc},1,[{types}]]" )
585
- } else {
586
- // The types list is only used for synthetic impls.
587
- // If this changes, `main.js` and `write_shared.rs` both need changed.
588
- format ! ( "[{text_esc}]" )
589
- }
581
+ crate :: html:: format:: display_fn ( |f| {
582
+ let text_esc = single_quote_string ( & self . text ) ;
583
+ if self . synthetic {
584
+ let types = crate :: html:: format:: comma_sep (
585
+ self . types . iter ( ) . map ( |type_| single_quote_string ( type_) ) ,
586
+ false ,
587
+ ) ;
588
+ // use `1` to represent a synthetic, because it's fewer bytes than `true`
589
+ write ! ( f, "[{text_esc},1,[{types}]]" )
590
+ } else {
591
+ // The types list is only used for synthetic impls.
592
+ // If this changes, `main.js` and `write_shared.rs` both need changed.
593
+ write ! ( f, "[{text_esc}]" )
594
+ }
595
+ } )
590
596
}
591
597
}
592
598
@@ -622,7 +628,10 @@ if (typeof exports !== 'undefined') {exports.searchIndex = searchIndex};
622
628
let implementors = format ! (
623
629
r#""{}":[{}]"# ,
624
630
krate. name( cx. tcx( ) ) ,
625
- implementors. iter( ) . map( Implementor :: to_js_string) . join( "," )
631
+ crate :: html:: format:: comma_sep(
632
+ implementors. iter( ) . map( Implementor :: to_js_string) ,
633
+ false
634
+ )
626
635
) ;
627
636
628
637
let mut mydst = dst. clone ( ) ;
0 commit comments