@@ -15,6 +15,18 @@ use crate::{
1515
1616use super :: { item_ty_to_section, Context , ItemSection } ;
1717
18+ #[ derive( Clone , Copy ) ]
19+ pub ( crate ) enum ModuleLike {
20+ Module ,
21+ Crate ,
22+ }
23+
24+ impl ModuleLike {
25+ pub ( crate ) fn is_crate ( self ) -> bool {
26+ matches ! ( self , ModuleLike :: Crate )
27+ }
28+ }
29+
1830#[ derive( Template ) ]
1931#[ template( path = "sidebar.html" ) ]
2032pub ( super ) struct Sidebar < ' a > {
@@ -530,14 +542,23 @@ fn sidebar_enum<'a>(
530542pub ( crate ) fn sidebar_module_like (
531543 item_sections_in_use : FxHashSet < ItemSection > ,
532544 ids : & mut IdMap ,
545+ module_like : ModuleLike ,
533546) -> LinkBlock < ' static > {
534- let item_sections = ItemSection :: ALL
547+ let item_sections: Vec < Link < ' _ > > = ItemSection :: ALL
535548 . iter ( )
536549 . copied ( )
537550 . filter ( |sec| item_sections_in_use. contains ( sec) )
538551 . map ( |sec| Link :: new ( ids. derive ( sec. id ( ) ) , sec. name ( ) ) )
539552 . collect ( ) ;
540- LinkBlock :: new ( Link :: empty ( ) , "" , item_sections)
553+ let header = if let Some ( first_section) = item_sections. get ( 0 ) {
554+ Link :: new (
555+ first_section. href . to_owned ( ) ,
556+ if module_like. is_crate ( ) { "Crate Items" } else { "Module Items" } ,
557+ )
558+ } else {
559+ Link :: empty ( )
560+ } ;
561+ LinkBlock :: new ( header, "" , item_sections)
541562}
542563
543564fn sidebar_module ( items : & [ clean:: Item ] , ids : & mut IdMap ) -> LinkBlock < ' static > {
@@ -561,7 +582,7 @@ fn sidebar_module(items: &[clean::Item], ids: &mut IdMap) -> LinkBlock<'static>
561582 . map ( |it| item_ty_to_section ( it. type_ ( ) ) )
562583 . collect ( ) ;
563584
564- sidebar_module_like ( item_sections_in_use, ids)
585+ sidebar_module_like ( item_sections_in_use, ids, ModuleLike :: Module )
565586}
566587
567588fn sidebar_foreign_type < ' a > (
0 commit comments