File tree Expand file tree Collapse file tree 3 files changed +25
-29
lines changed Expand file tree Collapse file tree 3 files changed +25
-29
lines changed Original file line number Diff line number Diff line change @@ -474,7 +474,7 @@ impl Options {
474
474
} ;
475
475
476
476
let mut id_map = html:: markdown:: IdMap :: new ( ) ;
477
- id_map. populate ( html:: render:: initial_ids ( ) ) ;
477
+ id_map. populate ( & html:: render:: INITIAL_IDS ) ;
478
478
let external_html = match ExternalHtml :: load (
479
479
& matches. opt_strs ( "html-in-header" ) ,
480
480
& matches. opt_strs ( "html-before-content" ) ,
Original file line number Diff line number Diff line change @@ -1332,7 +1332,7 @@ impl IdMap {
1332
1332
IdMap { map : init_id_map ( ) }
1333
1333
}
1334
1334
1335
- crate fn populate < I : IntoIterator < Item = String > > ( & mut self , ids : I ) {
1335
+ crate fn populate < I : IntoIterator < Item = S > , S : AsRef < str > + ToString > ( & mut self , ids : I ) {
1336
1336
for id in ids {
1337
1337
let _ = self . derive ( id) ;
1338
1338
}
@@ -1342,11 +1342,11 @@ impl IdMap {
1342
1342
self . map = init_id_map ( ) ;
1343
1343
}
1344
1344
1345
- crate fn derive ( & mut self , candidate : String ) -> String {
1346
- let id = match self . map . get_mut ( & candidate) {
1347
- None => candidate,
1345
+ crate fn derive < S : AsRef < str > + ToString > ( & mut self , candidate : S ) -> String {
1346
+ let id = match self . map . get_mut ( candidate. as_ref ( ) ) {
1347
+ None => candidate. to_string ( ) ,
1348
1348
Some ( a) => {
1349
- let id = format ! ( "{}-{}" , candidate, * a) ;
1349
+ let id = format ! ( "{}-{}" , candidate. as_ref ( ) , * a) ;
1350
1350
* a += 1 ;
1351
1351
id
1352
1352
}
Original file line number Diff line number Diff line change @@ -359,28 +359,24 @@ crate struct StylePath {
359
359
360
360
thread_local ! ( crate static CURRENT_DEPTH : Cell <usize > = Cell :: new( 0 ) ) ;
361
361
362
- crate fn initial_ids ( ) -> Vec < String > {
363
- [
364
- "main" ,
365
- "search" ,
366
- "help" ,
367
- "TOC" ,
368
- "render-detail" ,
369
- "associated-types" ,
370
- "associated-const" ,
371
- "required-methods" ,
372
- "provided-methods" ,
373
- "implementors" ,
374
- "synthetic-implementors" ,
375
- "implementors-list" ,
376
- "synthetic-implementors-list" ,
377
- "methods" ,
378
- "implementations" ,
379
- ]
380
- . iter ( )
381
- . map ( |id| ( String :: from ( * id) ) )
382
- . collect ( )
383
- }
362
+ // FIXME: make this work
363
+ crate const INITIAL_IDS : [ & ' static str ; 15 ] = [
364
+ "main" ,
365
+ "search" ,
366
+ "help" ,
367
+ "TOC" ,
368
+ "render-detail" ,
369
+ "associated-types" ,
370
+ "associated-const" ,
371
+ "required-methods" ,
372
+ "provided-methods" ,
373
+ "implementors" ,
374
+ "synthetic-implementors" ,
375
+ "implementors-list" ,
376
+ "synthetic-implementors-list" ,
377
+ "methods" ,
378
+ "implementations" ,
379
+ ] ;
384
380
385
381
/// Generates the documentation for `crate` into the directory `dst`
386
382
impl < ' tcx > FormatRenderer < ' tcx > for Context < ' tcx > {
@@ -1581,7 +1577,7 @@ impl Context<'_> {
1581
1577
1582
1578
{
1583
1579
self . id_map . borrow_mut ( ) . reset ( ) ;
1584
- self . id_map . borrow_mut ( ) . populate ( initial_ids ( ) ) ;
1580
+ self . id_map . borrow_mut ( ) . populate ( & INITIAL_IDS ) ;
1585
1581
}
1586
1582
1587
1583
if !self . render_redirect_pages {
You can’t perform that action at this time.
0 commit comments