]> git.lizzy.rs Git - rust.git/commitdiff
doc pages: add the ability to search unknown types
authorBrandon W Maister <quodlibetor@gmail.com>
Sat, 13 Feb 2016 20:11:08 +0000 (15:11 -0500)
committerBrandon W Maister <quodlibetor@gmail.com>
Sat, 13 Feb 2016 20:15:31 +0000 (15:15 -0500)
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.

src/librustdoc/html/layout.rs
src/librustdoc/html/static/main.js

index ffcd22fa8209604daeda1542306d22cc1e13c07a..975b4d3636f2d10b983fb0a79c61b6d92d550c01 100644 (file)
@@ -122,7 +122,7 @@ pub fn render<T: fmt::Display, S: fmt::Display>(
 
                 <p>
                     Search functions by type signature (e.g.
-                    <code>vec -> usize</code>)
+                    <code>vec -> usize</code> or <code>* -> vec</code>)
                 </p>
             </div>
         </div>
index 8844ed82bb5e29cd73c956d28ad56bee6d1a7451..08f70ae9ce7a0ec1896c7442a2cf50b43566ddfa 100644 (file)
                 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) {
 
                     // 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});
                     }
                 }