@@ -880,8 +880,8 @@ fn item_trait(w: &mut Buffer, cx: &mut Context<'_>, it: &clean::Item, t: &clean:
880
880
let ( mut synthetic, mut concrete) : ( Vec < & & Impl > , Vec < & & Impl > ) =
881
881
local. iter ( ) . partition ( |i| i. inner_impl ( ) . kind . is_auto ( ) ) ;
882
882
883
- synthetic. sort_by ( |a , b| compare_impl ( a , b , cx) ) ;
884
- concrete. sort_by ( |a , b| compare_impl ( a , b , cx) ) ;
883
+ synthetic. sort_by_cached_key ( |i| ImplString :: new ( i , cx) ) ;
884
+ concrete. sort_by_cached_key ( |i| ImplString :: new ( i , cx) ) ;
885
885
886
886
if !foreign. is_empty ( ) {
887
887
write_small_section_header ( w, "foreign-impls" , "Implementations on Foreign Types" , "" ) ;
@@ -1597,12 +1597,25 @@ where
1597
1597
w. write_str ( "</code></pre>" ) ;
1598
1598
}
1599
1599
1600
- fn compare_impl < ' a , ' b > ( lhs : & ' a & & Impl , rhs : & ' b & & Impl , cx : & Context < ' _ > ) -> Ordering {
1601
- let lhss = format ! ( "{}" , lhs. inner_impl( ) . print( false , cx) ) ;
1602
- let rhss = format ! ( "{}" , rhs. inner_impl( ) . print( false , cx) ) ;
1600
+ #[ derive( PartialEq , Eq ) ]
1601
+ struct ImplString ( String ) ;
1603
1602
1604
- // lhs and rhs are formatted as HTML, which may be unnecessary
1605
- compare_names ( & lhss, & rhss)
1603
+ impl ImplString {
1604
+ fn new ( i : & Impl , cx : & Context < ' _ > ) -> ImplString {
1605
+ ImplString ( format ! ( "{}" , i. inner_impl( ) . print( false , cx) ) )
1606
+ }
1607
+ }
1608
+
1609
+ impl PartialOrd for ImplString {
1610
+ fn partial_cmp ( & self , other : & Self ) -> Option < Ordering > {
1611
+ Some ( Ord :: cmp ( self , other) )
1612
+ }
1613
+ }
1614
+
1615
+ impl Ord for ImplString {
1616
+ fn cmp ( & self , other : & Self ) -> Ordering {
1617
+ compare_names ( & self . 0 , & other. 0 )
1618
+ }
1606
1619
}
1607
1620
1608
1621
fn render_implementor (
0 commit comments