Skip to content

Commit 94b6ddc

Browse files
committed
Rustdoc Search: Increase Relevance of Primitives
1 parent a713867 commit 94b6ddc

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/librustdoc/html/static/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@
3636
"constant",
3737
"associatedconstant"];
3838

39+
// used for special search precedence
40+
var TY_PRIMITIVE = itemTypes.indexOf("primitive");
41+
3942
$('.js-only').removeClass('js-only');
4043

4144
function getQueryStringParams() {
@@ -322,6 +325,10 @@
322325
b = bbb.index;
323326
if (a !== b) { return a - b; }
324327

328+
// special precedence for primitive pages
329+
if ((aaa.item.ty === TY_PRIMITIVE) && (bbb.item.ty !== TY_PRIMITIVE)) {
330+
return -1;
331+
}
325332

326333
// sort by description (no description goes later)
327334
a = (aaa.item.desc === '');

0 commit comments

Comments
 (0)