File tree 1 file changed +23
-29
lines changed
1 file changed +23
-29
lines changed Original file line number Diff line number Diff line change @@ -584,47 +584,41 @@ pub struct TopSymbolsCtx {
584
584
585
585
impl TopSymbolsCtx {
586
586
pub fn new ( ctx : & RenderContext ) -> Option < Self > {
587
- let partitions = super :: partition:: partition_nodes_by_name (
588
- & ctx
589
- . ctx
590
- . doc_nodes
591
- . values ( )
592
- . flatten ( )
593
- . cloned ( )
594
- . collect :: < Vec < _ > > ( ) ,
595
- true ,
596
- ) ;
587
+ let partitions = ctx
588
+ . ctx
589
+ . doc_nodes
590
+ . values ( )
591
+ . flat_map ( |nodes| super :: partition:: partition_nodes_by_name ( nodes, true ) )
592
+ . collect :: < Vec < _ > > ( ) ;
597
593
598
594
if partitions. is_empty ( ) {
599
595
return None ;
600
596
}
601
597
598
+ let total_symbols = partitions. len ( ) ;
599
+
602
600
let symbols = partitions
603
- . values ( )
601
+ . into_iter ( )
604
602
. take ( 5 )
605
- . map ( |nodes| {
606
- let name = nodes[ 0 ] . get_qualified_name ( ) ;
607
-
608
- TopSymbolCtx {
609
- kind : nodes
610
- . iter ( )
611
- . map ( |node| node. kind_with_drilldown . into ( ) )
612
- . collect :: < Vec < _ > > ( ) ,
613
- href : ctx. ctx . href_resolver . resolve_path (
614
- ctx. get_current_resolve ( ) ,
615
- UrlResolveKind :: Symbol {
616
- file : & nodes[ 0 ] . origin ,
617
- symbol : & name,
618
- } ,
619
- ) ,
620
- name,
621
- }
603
+ . map ( |( name, nodes) | TopSymbolCtx {
604
+ kind : nodes
605
+ . iter ( )
606
+ . map ( |node| node. kind_with_drilldown . into ( ) )
607
+ . collect :: < Vec < _ > > ( ) ,
608
+ href : ctx. ctx . href_resolver . resolve_path (
609
+ ctx. get_current_resolve ( ) ,
610
+ UrlResolveKind :: Symbol {
611
+ file : & nodes[ 0 ] . origin ,
612
+ symbol : & name,
613
+ } ,
614
+ ) ,
615
+ name,
622
616
} )
623
617
. collect ( ) ;
624
618
625
619
Some ( Self {
626
620
symbols,
627
- total_symbols : partitions . values ( ) . count ( ) ,
621
+ total_symbols,
628
622
all_symbols_href : ctx
629
623
. ctx
630
624
. href_resolver
You can’t perform that action at this time.
0 commit comments