@@ -100,9 +100,21 @@ 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+ self . 0 . as_str ( ) . serialize ( serializer)
111+ }
112+ }
113+
114+ type AliasMap = BTreeMap < SerSymbolAsStr , Vec < usize > > ;
103115 // Aliases added through `#[doc(alias = "...")]`. Since a few items can have the same alias,
104116 // we need the alias element to have an array of items.
105- let mut aliases: BTreeMap < String , Vec < usize > > = BTreeMap :: new ( ) ;
117+ let mut aliases: AliasMap = BTreeMap :: new ( ) ;
106118
107119 // Sort search index items. This improves the compressibility of the search index.
108120 cache. search_index . sort_unstable_by ( |k1, k2| {
@@ -116,7 +128,7 @@ pub(crate) fn build_index(
116128 // Set up alias indexes.
117129 for ( i, item) in cache. search_index . iter ( ) . enumerate ( ) {
118130 for alias in & item. aliases [ ..] {
119- aliases. entry ( alias . to_string ( ) ) . or_default ( ) . push ( i) ;
131+ aliases. entry ( SerSymbolAsStr ( * alias ) ) . or_default ( ) . push ( i) ;
120132 }
121133 }
122134
@@ -474,7 +486,7 @@ pub(crate) fn build_index(
474486 // The String is alias name and the vec is the list of the elements with this alias.
475487 //
476488 // To be noted: the `usize` elements are indexes to `items`.
477- aliases : & ' a BTreeMap < String , Vec < usize > > ,
489+ aliases : & ' a AliasMap ,
478490 // Used when a type has more than one impl with an associated item with the same name.
479491 associated_item_disambiguators : & ' a Vec < ( usize , String ) > ,
480492 // A list of shard lengths encoded as vlqhex. See the comment in write_vlqhex_to_string
0 commit comments