I'm announcing an initial version of an API search tool for Rust called Rustle. 
It is inspired by the api search tool for Haskell 
called Hoogle (http://www.haskell.org/hoogle). It is quite new, but can already 
do some useful things. You can install it
for yourself (http://github.com/dbp/rustle) and run it at the commandline, or 
use the (experimental) web version at 
http://lab.dbpmail.net/rustle/.

Some example queries it can can respond to (command line responses shown, but 
the web-app is similar):

rustle> Either<A,B> -> A
core::either::unwrap_left - fn unwrap_left<T, U>(eith: Either<T, U>) -> T - 
Retrieves the value in the left branch. 
Fails if the either is Right.

rustle> ([A], fn(A)->B) -> [B]
core::vec::map - fn map<T, U>(v: & [T], f: fn&(t: & T) -> U) -> ~[U] - Apply a 
function to each element of a vector and return the results
core::vec::map_consume - fn map_consume<T, U>(v: ~[T], f: fn&(v: T) -> U) -> 
~[U] - 
...

rustle> Either<uint,uint> -> uint
core::either::unwrap_left - fn unwrap_left<T, U>(eith: Either<T, U>) -> T - 
Retrieves the value in the left 
branch. Fails if the either is Right.
core::either::unwrap_right - fn unwrap_right<T, U>(eith: Either<T, U>) -> U - 
Retrieves the value in the 
right branch. Fails if the either is Left.

rustle> Option<D>,Option<D> -> Option<D>
core::option::or - fn or<T>(opta: Option<T>, optb: Option<T>) -> Option<T> - 
Returns the leftmost some() 
value, or none if both are none.

rustle> each
core::str::each - fn each(s: & str, it: fn&(u8) -> bool) - Iterate over the 
bytes in a string
core::vec::each - fn each<T>(v: &r/[T], f: fn&(&r/T) -> bool) - Iterates over a 
vector, with option to break
...
core::vec::each_mut - fn each_mut<T>(v: & [mut T], f: fn&(elem: & mut T) -> 
bool) - Like 
core::vec::each_permutation - fn each_permutation<T: Copy>(v: & [T], put: 
fn&(ts: & [T]) -> bool) - 
Iterate over all permutations of vector 
...

It will search for functions by types (with tolerance to renamed type variables 
- i.e., Option<D> 
matches Option<T>). It will also try to look for more general functions (i.e., 
Option<uint> -> uint 
matches Option<T> -> T), and rearrange the order of arguments. There is limited 
support for methods - 
we include ones declared on types, but not ones that come through traits.

There are also massive simplifications - all pointer types are ignored (with 
the intent being that for
searching, you want to see all variants), all single letter uppercase types are 
treated as polymorphic 
(so trait constraints are ignored), and the only heuristic for results is the 
order I chose to import the modules.
You can search for functions by names, but only prefixes (this limit will go 
away eventually). On the other hand, 
it already does some neat things!

To try it out, contribute, improve, file bugs, etc, go to 
http://github.com/dbp/rustle . The readme 
should explain how to get started with it. You can also try it out at 
http://lab.dbpmail.net/rustle/. The
web frontend is currently very basic, but it does link to the official 
documentation. It is all written in rust,
except the html scraper (which is not needed to run it).

Feedback welcome!
Daniel

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to