diff options
| author | Brandon W Maister <quodlibetor@gmail.com> | 2016-02-13 15:11:08 -0500 |
|---|---|---|
| committer | Brandon W Maister <quodlibetor@gmail.com> | 2016-02-13 15:15:31 -0500 |
| commit | 2fd7701dd6700b71e8157e31430508ba830b96ac (patch) | |
| tree | 1f85dddf90da4852616bed9e37e30e4757c95181 /src | |
| parent | 4b7245047b802f8e01c824a6efd8197da8be82fb (diff) | |
| download | rust-2fd7701dd6700b71e8157e31430508ba830b96ac.tar.gz rust-2fd7701dd6700b71e8157e31430508ba830b96ac.zip | |
doc pages: add the ability to search unknown types
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 #31598, but I've wanted it several times when exploring new crates.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustdoc/html/layout.rs | 2 | ||||
| -rw-r--r-- | src/librustdoc/html/static/main.js | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index ffcd22fa820..975b4d3636f 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -122,7 +122,7 @@ r##"<!DOCTYPE html> <p> Search functions by type signature (e.g. - <code>vec -> usize</code>) + <code>vec -> usize</code> or <code>* -> vec</code>) </p> </div> </div> diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 8844ed82bb5..08f70ae9ce7 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -280,7 +280,7 @@ var parts = val.split("->").map(trimmer); var input = parts[0]; // sort inputs so that order does not matter - var inputs = input.split(",").map(trimmer).sort(); + var inputs = input.split(",").map(trimmer).sort().toString(); var output = parts[1]; for (var i = 0; i < nSearchWords; ++i) { @@ -296,8 +296,8 @@ // allow searching for void (no output) functions as well var typeOutput = type.output ? type.output.name : ""; - if (inputs.toString() === typeInputs.toString() && - output == typeOutput) { + if ((inputs === "*" || inputs === typeInputs.toString()) && + (output === "*" || output == typeOutput)) { results.push({id: i, index: -1, dontValidate: true}); } } |
