Skip to content

Commit fffedb1

Browse files
committed
Rollup merge of rust-lang#31639 - quodlibetor:doc-search-with-unknown-types, r=alexcrichton
This enables `*` in all type positions in doc searches, which I often want in order to find functions that create or convert specific types (e.g. `* -> vec`) but I don't actually know what kinds of input they expect. I actually started working on this because of rust-lang#31598, but I've wanted it several times when exploring new crates.
2 parents c078e34 + 2fd7701 commit fffedb1

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/librustdoc/html/layout.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ r##"<!DOCTYPE html>
122122
123123
<p>
124124
Search functions by type signature (e.g.
125-
<code>vec -> usize</code>)
125+
<code>vec -> usize</code> or <code>* -> vec</code>)
126126
</p>
127127
</div>
128128
</div>

src/librustdoc/html/static/main.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
var parts = val.split("->").map(trimmer);
281281
var input = parts[0];
282282
// sort inputs so that order does not matter
283-
var inputs = input.split(",").map(trimmer).sort();
283+
var inputs = input.split(",").map(trimmer).sort().toString();
284284
var output = parts[1];
285285

286286
for (var i = 0; i < nSearchWords; ++i) {
@@ -296,8 +296,8 @@
296296

297297
// allow searching for void (no output) functions as well
298298
var typeOutput = type.output ? type.output.name : "";
299-
if (inputs.toString() === typeInputs.toString() &&
300-
output == typeOutput) {
299+
if ((inputs === "*" || inputs === typeInputs.toString()) &&
300+
(output === "*" || output == typeOutput)) {
301301
results.push({id: i, index: -1, dontValidate: true});
302302
}
303303
}

0 commit comments

Comments
 (0)