@@ -320,8 +320,8 @@ window.initSearch = rawSearchIndex => {
320
320
if ( foundExclamation ) {
321
321
throw new Error ( "Cannot have more than one `!` in an ident" ) ;
322
322
} else if ( parserState . pos + 1 < parserState . length &&
323
- isIdentCharacter ( parserState . userQuery [ parserState . pos + 1 ] ) )
324
- {
323
+ isIdentCharacter ( parserState . userQuery [ parserState . pos + 1 ] )
324
+ ) {
325
325
throw new Error ( "`!` can only be at the end of an ident" ) ;
326
326
}
327
327
foundExclamation = true ;
@@ -330,12 +330,10 @@ window.initSearch = rawSearchIndex => {
330
330
} else if (
331
331
isStopCharacter ( c ) ||
332
332
isSpecialStartCharacter ( c ) ||
333
- isSeparatorCharacter ( c ) )
334
- {
333
+ isSeparatorCharacter ( c )
334
+ ) {
335
335
break ;
336
- }
337
- // If we allow paths ("str::string" for example).
338
- else if ( c === ":" ) {
336
+ } else if ( c === ":" ) { // If we allow paths ("str::string" for example).
339
337
if ( ! isPathStart ( parserState ) ) {
340
338
break ;
341
339
}
@@ -372,8 +370,8 @@ window.initSearch = rawSearchIndex => {
372
370
end = getIdentEndPosition ( parserState ) ;
373
371
}
374
372
if ( parserState . pos < parserState . length &&
375
- parserState . userQuery [ parserState . pos ] === "<" )
376
- {
373
+ parserState . userQuery [ parserState . pos ] === "<"
374
+ ) {
377
375
if ( isInGenerics ) {
378
376
throw new Error ( "Unexpected `<` after `<`" ) ;
379
377
} else if ( start >= end ) {
@@ -592,8 +590,8 @@ window.initSearch = rawSearchIndex => {
592
590
593
591
if ( elem &&
594
592
elem . value !== "All crates" &&
595
- hasOwnPropertyRustdoc ( rawSearchIndex , elem . value ) )
596
- {
593
+ hasOwnPropertyRustdoc ( rawSearchIndex , elem . value )
594
+ ) {
597
595
return elem . value ;
598
596
}
599
597
return null ;
@@ -786,37 +784,51 @@ window.initSearch = rawSearchIndex => {
786
784
// sort by exact match with regard to the last word (mismatch goes later)
787
785
a = ( aaa . word !== userQuery ) ;
788
786
b = ( bbb . word !== userQuery ) ;
789
- if ( a !== b ) { return a - b ; }
787
+ if ( a !== b ) {
788
+ return a - b ;
789
+ }
790
790
791
791
// Sort by non levenshtein results and then levenshtein results by the distance
792
792
// (less changes required to match means higher rankings)
793
793
a = ( aaa . lev ) ;
794
794
b = ( bbb . lev ) ;
795
- if ( a !== b ) { return a - b ; }
795
+ if ( a !== b ) {
796
+ return a - b ;
797
+ }
796
798
797
799
// sort by crate (non-current crate goes later)
798
800
a = ( aaa . item . crate !== window . currentCrate ) ;
799
801
b = ( bbb . item . crate !== window . currentCrate ) ;
800
- if ( a !== b ) { return a - b ; }
802
+ if ( a !== b ) {
803
+ return a - b ;
804
+ }
801
805
802
806
// sort by item name length (longer goes later)
803
807
a = aaa . word . length ;
804
808
b = bbb . word . length ;
805
- if ( a !== b ) { return a - b ; }
809
+ if ( a !== b ) {
810
+ return a - b ;
811
+ }
806
812
807
813
// sort by item name (lexicographically larger goes later)
808
814
a = aaa . word ;
809
815
b = bbb . word ;
810
- if ( a !== b ) { return ( a > b ? + 1 : - 1 ) ; }
816
+ if ( a !== b ) {
817
+ return ( a > b ? + 1 : - 1 ) ;
818
+ }
811
819
812
820
// sort by index of keyword in item name (no literal occurrence goes later)
813
821
a = ( aaa . index < 0 ) ;
814
822
b = ( bbb . index < 0 ) ;
815
- if ( a !== b ) { return a - b ; }
823
+ if ( a !== b ) {
824
+ return a - b ;
825
+ }
816
826
// (later literal occurrence, if any, goes later)
817
827
a = aaa . index ;
818
828
b = bbb . index ;
819
- if ( a !== b ) { return a - b ; }
829
+ if ( a !== b ) {
830
+ return a - b ;
831
+ }
820
832
821
833
// special precedence for primitive and keyword pages
822
834
if ( ( aaa . item . ty === TY_PRIMITIVE && bbb . item . ty !== TY_KEYWORD ) ||
@@ -831,17 +843,23 @@ window.initSearch = rawSearchIndex => {
831
843
// sort by description (no description goes later)
832
844
a = ( aaa . item . desc === "" ) ;
833
845
b = ( bbb . item . desc === "" ) ;
834
- if ( a !== b ) { return a - b ; }
846
+ if ( a !== b ) {
847
+ return a - b ;
848
+ }
835
849
836
850
// sort by type (later occurrence in `itemTypes` goes later)
837
851
a = aaa . item . ty ;
838
852
b = bbb . item . ty ;
839
- if ( a !== b ) { return a - b ; }
853
+ if ( a !== b ) {
854
+ return a - b ;
855
+ }
840
856
841
857
// sort by path (lexicographically larger goes later)
842
858
a = aaa . item . path ;
843
859
b = bbb . item . path ;
844
- if ( a !== b ) { return ( a > b ? + 1 : - 1 ) ; }
860
+ if ( a !== b ) {
861
+ return ( a > b ? + 1 : - 1 ) ;
862
+ }
845
863
846
864
// que sera, sera
847
865
return 0 ;
@@ -1315,16 +1333,15 @@ window.initSearch = rawSearchIndex => {
1315
1333
}
1316
1334
1317
1335
if ( searchWord . indexOf ( elem . pathLast ) > - 1 ||
1318
- row . normalizedName . indexOf ( elem . pathLast ) > - 1 )
1319
- {
1336
+ row . normalizedName . indexOf ( elem . pathLast ) > - 1
1337
+ ) {
1320
1338
// filter type: ... queries
1321
1339
if ( ! results_others [ fullId ] !== undefined ) {
1322
1340
index = row . normalizedName . indexOf ( elem . pathLast ) ;
1323
1341
}
1324
1342
}
1325
1343
lev = levenshtein ( searchWord , elem . pathLast ) ;
1326
- if ( lev > 0 && elem . pathLast . length > 2 && searchWord . indexOf ( elem . pathLast ) > - 1 )
1327
- {
1344
+ if ( lev > 0 && elem . pathLast . length > 2 && searchWord . indexOf ( elem . pathLast ) > - 1 ) {
1328
1345
if ( elem . pathLast . length < 6 ) {
1329
1346
lev = 1 ;
1330
1347
} else {
@@ -1670,8 +1687,8 @@ window.initSearch = rawSearchIndex => {
1670
1687
// By default, the search DOM element is "empty" (meaning it has no children not
1671
1688
// text content). Once a search has been run, it won't be empty, even if you press
1672
1689
// ESC or empty the search input (which also "cancels" the search).
1673
- && ( ! search . firstChild || search . firstChild . innerText !== searchState . loadingText ) ) )
1674
- {
1690
+ && ( ! search . firstChild || search . firstChild . innerText !== searchState . loadingText ) )
1691
+ ) {
1675
1692
const elem = document . createElement ( "a" ) ;
1676
1693
elem . href = results . others [ 0 ] . href ;
1677
1694
removeClass ( elem , "active" ) ;
@@ -1766,7 +1783,7 @@ window.initSearch = rawSearchIndex => {
1766
1783
let i = 0 ;
1767
1784
for ( const elem of elems ) {
1768
1785
const j = i ;
1769
- elem . onclick = ( ) => { printTab ( j ) ; } ;
1786
+ elem . onclick = ( ) => printTab ( j ) ;
1770
1787
searchState . focusedByTab . push ( null ) ;
1771
1788
i += 1 ;
1772
1789
}
0 commit comments