@@ -361,6 +361,7 @@ impl ToJson for IndexItem {
361
361
/// A type used for the search index.
362
362
struct Type {
363
363
name : Option < String > ,
364
+ generics : Option < Vec < String > > ,
364
365
}
365
366
366
367
impl ToJson for Type {
@@ -369,6 +370,9 @@ impl ToJson for Type {
369
370
Some ( ref name) => {
370
371
let mut data = BTreeMap :: new ( ) ;
371
372
data. insert ( "name" . to_owned ( ) , name. to_json ( ) ) ;
373
+ if let Some ( ref generics) = self . generics {
374
+ data. insert ( "generics" . to_owned ( ) , generics. to_json ( ) ) ;
375
+ }
372
376
Json :: Object ( data)
373
377
} ,
374
378
None => Json :: Null
@@ -420,7 +424,7 @@ fn init_ids() -> FxHashMap<String, usize> {
420
424
"methods" ,
421
425
"deref-methods" ,
422
426
"implementations" ,
423
- ] . into_iter ( ) . map ( |id| ( String :: from ( * id) , 1 ) ) . collect ( )
427
+ ] . into_iter ( ) . map ( |id| ( String :: from ( * id) , 1 ) ) . collect ( )
424
428
}
425
429
426
430
/// This method resets the local table of used ID attributes. This is typically
@@ -667,7 +671,6 @@ fn concise_compared_strs(s1: &str, s2: &str) -> (String, String) {
667
671
( format ! ( "...{}" , concise_str( s1) ) , format ! ( "...{}" , concise_str( s2) ) )
668
672
}
669
673
670
-
671
674
fn print_message ( msg : & str , intro_msg : & mut bool , span : & Span , text : & str ) {
672
675
if !* intro_msg {
673
676
println ! ( "WARNING: documentation for this crate may be rendered \
@@ -3956,23 +3959,42 @@ fn get_index_search_type(item: &clean::Item) -> Option<IndexItemFunctionType> {
3956
3959
}
3957
3960
3958
3961
fn get_index_type ( clean_type : & clean:: Type ) -> Type {
3959
- Type { name : get_index_type_name ( clean_type) . map ( |s| s. to_ascii_lowercase ( ) ) }
3962
+ let t = Type {
3963
+ name : get_index_type_name ( clean_type, true ) . map ( |s| s. to_ascii_lowercase ( ) ) ,
3964
+ generics : get_generics ( clean_type) ,
3965
+ } ;
3966
+ t
3960
3967
}
3961
3968
3962
- fn get_index_type_name ( clean_type : & clean:: Type ) -> Option < String > {
3969
+ fn get_index_type_name ( clean_type : & clean:: Type , accept_generic : bool ) -> Option < String > {
3963
3970
match * clean_type {
3964
3971
clean:: ResolvedPath { ref path, .. } => {
3965
3972
let segments = & path. segments ;
3966
3973
Some ( segments[ segments. len ( ) - 1 ] . name . clone ( ) )
3967
- } ,
3968
- clean:: Generic ( ref s) => Some ( s. clone ( ) ) ,
3974
+ }
3975
+ clean:: Generic ( ref s) if accept_generic => Some ( s. clone ( ) ) ,
3969
3976
clean:: Primitive ( ref p) => Some ( format ! ( "{:?}" , p) ) ,
3970
- clean:: BorrowedRef { ref type_, .. } => get_index_type_name ( type_) ,
3977
+ clean:: BorrowedRef { ref type_, .. } => get_index_type_name ( type_, accept_generic ) ,
3971
3978
// FIXME: add all from clean::Type.
3972
3979
_ => None
3973
3980
}
3974
3981
}
3975
3982
3983
+ fn get_generics ( clean_type : & clean:: Type ) -> Option < Vec < String > > {
3984
+ clean_type. generics ( )
3985
+ . and_then ( |types| {
3986
+ let r = types. iter ( )
3987
+ . filter_map ( |t| get_index_type_name ( t, false ) )
3988
+ . map ( |s| s. to_ascii_lowercase ( ) )
3989
+ . collect :: < Vec < _ > > ( ) ;
3990
+ if r. is_empty ( ) {
3991
+ None
3992
+ } else {
3993
+ Some ( r)
3994
+ }
3995
+ } )
3996
+ }
3997
+
3976
3998
pub fn cache ( ) -> Arc < Cache > {
3977
3999
CACHE_KEY . with ( |c| c. borrow ( ) . clone ( ) )
3978
4000
}
0 commit comments