@@ -35,6 +35,35 @@ const itemTypes = [
3535 "traitalias" ,
3636] ;
3737
38+ const longItemTypes = [
39+ "module" ,
40+ "extern crate" ,
41+ "re-export" ,
42+ "struct" ,
43+ "enum" ,
44+ "function" ,
45+ "type alias" ,
46+ "static" ,
47+ "trait" ,
48+ "" ,
49+ "trait method" ,
50+ "method" ,
51+ "struct field" ,
52+ "enum variant" ,
53+ "macro" ,
54+ "primitive type" ,
55+ "associated type" ,
56+ "constant" ,
57+ "associated constant" ,
58+ "union" ,
59+ "foreign type" ,
60+ "keyword" ,
61+ "existential type" ,
62+ "attribute macro" ,
63+ "derive macro" ,
64+ "trait alias" ,
65+ ] ;
66+
3867// used for special search precedence
3968const TY_PRIMITIVE = itemTypes . indexOf ( "primitive" ) ;
4069const TY_KEYWORD = itemTypes . indexOf ( "keyword" ) ;
@@ -1836,16 +1865,11 @@ function initSearch(rawSearchIndex) {
18361865 array . forEach ( item => {
18371866 const name = item . name ;
18381867 const type = itemTypes [ item . ty ] ;
1868+ const longType = longItemTypes [ item . ty ] ;
1869+ let extra = longType . length !== 0 ? ` <i>(${ longType } )</i>` : "" ;
18391870
18401871 length += 1 ;
18411872
1842- let extra = "" ;
1843- if ( type === "primitive" ) {
1844- extra = " <i>(primitive type)</i>" ;
1845- } else if ( type === "keyword" ) {
1846- extra = " <i>(keyword)</i>" ;
1847- }
1848-
18491873 const link = document . createElement ( "a" ) ;
18501874 link . className = "result-" + type ;
18511875 link . href = item . href ;
@@ -1854,6 +1878,7 @@ function initSearch(rawSearchIndex) {
18541878 resultName . className = "result-name" ;
18551879
18561880 if ( item . is_alias ) {
1881+ extra = "" ;
18571882 const alias = document . createElement ( "span" ) ;
18581883 alias . className = "alias" ;
18591884
@@ -1863,13 +1888,13 @@ function initSearch(rawSearchIndex) {
18631888
18641889 alias . insertAdjacentHTML (
18651890 "beforeend" ,
1866- "<span class=\"grey\"><i> - see </i></span >" ) ;
1891+ "<i class=\"grey\"> - see </i>" ) ;
18671892
18681893 resultName . appendChild ( alias ) ;
18691894 }
18701895 resultName . insertAdjacentHTML (
18711896 "beforeend" ,
1872- item . displayPath + "<span class=\"" + type + "\">" + name + extra + "</span>" ) ;
1897+ item . displayPath + "<span class=\"" + type + "\">" + name + "</span>" + extra ) ;
18731898 link . appendChild ( resultName ) ;
18741899
18751900 const description = document . createElement ( "div" ) ;
0 commit comments