@@ -439,24 +439,20 @@ impl CratesIndexPart {
439
439
let content =
440
440
format ! ( "<h1>List of all crates</h1><ul class=\" all-items\" >{DELIMITER}</ul>" ) ;
441
441
let template = layout:: render ( layout, & page, "" , content, style_files) ;
442
- match SortedTemplate :: from_template ( & template, DELIMITER ) {
443
- Ok ( template) => template,
444
- Err ( e) => panic ! (
445
- "Object Replacement Character (U+FFFC) should not appear in the --index-page: {e}"
446
- ) ,
447
- }
442
+ SortedTemplate :: from_template ( & template, DELIMITER )
443
+ . expect ( "Object Replacement Character (U+FFFC) should not appear in the --index-page" )
448
444
}
449
445
450
446
/// Might return parts that are duplicate with ones in prexisting index.html
451
447
fn get ( crate_name : & str , external_crates : & [ String ] ) -> Result < PartsAndLocations < Self > , Error > {
452
448
let mut ret = PartsAndLocations :: default ( ) ;
453
- let path = PathBuf :: from ( "index.html" ) ;
449
+ let path = Path :: new ( "index.html" ) ;
454
450
for crate_name in external_crates. iter ( ) . map ( |s| s. as_str ( ) ) . chain ( once ( crate_name) ) {
455
451
let part = format ! (
456
452
"<li><a href=\" {trailing_slash}index.html\" >{crate_name}</a></li>" ,
457
453
trailing_slash = ensure_trailing_slash( crate_name) ,
458
454
) ;
459
- ret. push ( path. clone ( ) , part) ;
455
+ ret. push ( path. to_path_buf ( ) , part) ;
460
456
}
461
457
Ok ( ret)
462
458
}
@@ -737,7 +733,7 @@ impl TraitAliasPart {
737
733
} ,
738
734
} ;
739
735
740
- let implementors = imps
736
+ let mut implementors = imps
741
737
. iter ( )
742
738
. filter_map ( |imp| {
743
739
// If the trait and implementation are in the same crate, then
@@ -759,12 +755,12 @@ impl TraitAliasPart {
759
755
} )
760
756
}
761
757
} )
762
- . collect :: < Vec < _ > > ( ) ;
758
+ . peekable ( ) ;
763
759
764
760
// Only create a js file if we have impls to add to it. If the trait is
765
761
// documented locally though we always create the file to avoid dead
766
762
// links.
767
- if implementors. is_empty ( ) && !cache. paths . contains_key ( & did) {
763
+ if implementors. peek ( ) . is_none ( ) && !cache. paths . contains_key ( & did) {
768
764
continue ;
769
765
}
770
766
@@ -775,11 +771,7 @@ impl TraitAliasPart {
775
771
path. push ( format ! ( "{remote_item_type}.{}.js" , remote_path[ remote_path. len( ) - 1 ] ) ) ;
776
772
777
773
let part = OrderedJson :: array_sorted (
778
- implementors
779
- . iter ( )
780
- . map ( OrderedJson :: serialize)
781
- . collect :: < Result < Vec < _ > , _ > > ( )
782
- . unwrap ( ) ,
774
+ implementors. map ( |implementor| OrderedJson :: serialize ( implementor) . unwrap ( ) ) ,
783
775
) ;
784
776
path_parts. push ( path, OrderedJson :: array_unsorted ( [ crate_name_json, & part] ) ) ;
785
777
}
@@ -874,9 +866,8 @@ impl<'item> DocVisitor<'item> for TypeImplCollector<'_, '_, 'item> {
874
866
let impl_ = cache
875
867
. impls
876
868
. get ( & target_did)
877
- . map ( |v| & v[ ..] )
878
- . unwrap_or_default ( )
879
- . iter ( )
869
+ . into_iter ( )
870
+ . flatten ( )
880
871
. map ( |impl_| {
881
872
( impl_. impl_item . item_id , AliasedTypeImpl { impl_, type_aliases : Vec :: new ( ) } )
882
873
} )
@@ -891,14 +882,8 @@ impl<'item> DocVisitor<'item> for TypeImplCollector<'_, '_, 'item> {
891
882
// Exclude impls that are directly on this type. They're already in the HTML.
892
883
// Some inlining scenarios can cause there to be two versions of the same
893
884
// impl: one on the type alias and one on the underlying target type.
894
- let mut seen_impls: FxHashSet < ItemId > = cache
895
- . impls
896
- . get ( & self_did)
897
- . map ( |s| & s[ ..] )
898
- . unwrap_or_default ( )
899
- . iter ( )
900
- . map ( |i| i. impl_item . item_id )
901
- . collect ( ) ;
885
+ let mut seen_impls: FxHashSet < ItemId > =
886
+ cache. impls . get ( & self_did) . into_iter ( ) . flatten ( ) . map ( |i| i. impl_item . item_id ) . collect ( ) ;
902
887
for ( impl_item_id, aliased_type_impl) in & mut aliased_type. impl_ {
903
888
// Only include this impl if it actually unifies with this alias.
904
889
// Synthetic impls are not included; those are also included in the HTML.
0 commit comments