I've just had my first non-trivial contribution to Rust merged. It adds basic type search functionality (a la Hoogle ) to rustdoc generated documentation.
The change is live on nightly builds, and you can already see it in action .
demo of searching for
charext -> boolin the stdlib docs
The current feature set includes:
- searching by type (you can use generics as well, as long as you use the exact name: vec, t -> )
- the order of function arguments is not relevant (so you don't have to remember it)
-
self's type is took into account (e.g.Vec::lenisvec -> usize) -
reference types are treated as basic types (e.g.
char, not&char)
If you are interested in the technical details, I suggest you check out the original issues , as well as the PR . While this is in no way comparable to a full fledged implementation like Hoogle's, the basic searching need is covered, and I hope that it will at least help other newbies like me explore the standard library, if nothing else.
There are plenty of enhancements to be made, so if you feel like contributing, here are a few ideas:
-
proper support for generics (
char -> charshould matcht -> t) -
smart ranking (
char -> charshould first matchchar -> charresults, and thent -> t) -
support for complex, wrapped types (e.g.
Rc<Vec<T>>) -
look for trait implementors (
char -> boolshould includecharext -> boolresults) - use compression for the search index (it was pretty large to begin with and it takes up even more space now, with the type information)
Last but not least, I'd like to give kudos to the Rust community. They were extremely helpful, both on IRC and on GitHub, and this helped make a daunting task (at first) seem doable!
Happy hacking!