@@ -100,9 +100,22 @@ pub(crate) fn build_index(
100100 let crate_doc =
101101 short_markdown_summary ( & krate. module . doc_value ( ) , & krate. module . link_names ( cache) ) ;
102102
103+ #[ derive( Eq , Ord , PartialEq , PartialOrd ) ]
104+ struct SerSymbolAsStr ( Symbol ) ;
105+
106+ impl Serialize for SerSymbolAsStr {
107+ fn serialize < S > ( & self , serializer : S ) -> Result < S :: Ok , S :: Error >
108+ where
109+ S : Serializer ,
110+ {
111+ self . 0 . as_str ( ) . serialize ( serializer)
112+ }
113+ }
114+
115+ type AliasMap = BTreeMap < SerSymbolAsStr , Vec < usize > > ;
103116 // Aliases added through `#[doc(alias = "...")]`. Since a few items can have the same alias,
104117 // we need the alias element to have an array of items.
105- let mut aliases: BTreeMap < String , Vec < usize > > = BTreeMap :: new ( ) ;
118+ let mut aliases: AliasMap = BTreeMap :: new ( ) ;
106119
107120 // Sort search index items. This improves the compressibility of the search index.
108121 cache. search_index . sort_unstable_by ( |k1, k2| {
@@ -116,7 +129,7 @@ pub(crate) fn build_index(
116129 // Set up alias indexes.
117130 for ( i, item) in cache. search_index . iter ( ) . enumerate ( ) {
118131 for alias in & item. aliases [ ..] {
119- aliases. entry ( alias . to_string ( ) ) . or_default ( ) . push ( i) ;
132+ aliases. entry ( SerSymbolAsStr ( * alias ) ) . or_default ( ) . push ( i) ;
120133 }
121134 }
122135
@@ -474,7 +487,7 @@ pub(crate) fn build_index(
474487 // The String is alias name and the vec is the list of the elements with this alias.
475488 //
476489 // To be noted: the `usize` elements are indexes to `items`.
477- aliases : & ' a BTreeMap < String , Vec < usize > > ,
490+ aliases : & ' a AliasMap ,
478491 // Used when a type has more than one impl with an associated item with the same name.
479492 associated_item_disambiguators : & ' a Vec < ( usize , String ) > ,
480493 // A list of shard lengths encoded as vlqhex. See the comment in write_vlqhex_to_string
0 commit comments