@@ -100,9 +100,22 @@ pub(crate) fn build_index(
100
100
let crate_doc =
101
101
short_markdown_summary ( & krate. module . doc_value ( ) , & krate. module . link_names ( cache) ) ;
102
102
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 > > ;
103
116
// Aliases added through `#[doc(alias = "...")]`. Since a few items can have the same alias,
104
117
// 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 ( ) ;
106
119
107
120
// Sort search index items. This improves the compressibility of the search index.
108
121
cache. search_index . sort_unstable_by ( |k1, k2| {
@@ -116,7 +129,7 @@ pub(crate) fn build_index(
116
129
// Set up alias indexes.
117
130
for ( i, item) in cache. search_index . iter ( ) . enumerate ( ) {
118
131
for alias in & item. aliases [ ..] {
119
- aliases. entry ( alias . to_string ( ) ) . or_default ( ) . push ( i) ;
132
+ aliases. entry ( SerSymbolAsStr ( * alias ) ) . or_default ( ) . push ( i) ;
120
133
}
121
134
}
122
135
@@ -474,7 +487,7 @@ pub(crate) fn build_index(
474
487
// The String is alias name and the vec is the list of the elements with this alias.
475
488
//
476
489
// To be noted: the `usize` elements are indexes to `items`.
477
- aliases : & ' a BTreeMap < String , Vec < usize > > ,
490
+ aliases : & ' a AliasMap ,
478
491
// Used when a type has more than one impl with an associated item with the same name.
479
492
associated_item_disambiguators : & ' a Vec < ( usize , String ) > ,
480
493
// A list of shard lengths encoded as vlqhex. See the comment in write_vlqhex_to_string
0 commit comments