@@ -72,6 +72,7 @@ the standard library and functions that are included in the results list:
7272| [ ` stdout, [u8] ` ] [ stdoutu8 ] | ` Stdout::write ` |
7373| [ ` any -> ! ` ] [ ] | ` panic::panic_any ` |
7474| [ ` vec::intoiter<T> -> [T] ` ] [ iterasslice ] | ` IntoIter::as_slice ` and ` IntoIter::next_chunk ` |
75+ | [ ` iterator<T>, fnmut -> T ` ] [ iterreduce ] | ` Iterator::reduce ` and ` Iterator::find ` |
7576
7677[ `usize -> vec` ] : ../../std/vec/struct.Vec.html?search=usize%20-%3E%20vec&filter-crate=std
7778[ `vec, vec -> bool` ] : ../../std/vec/struct.Vec.html?search=vec,%20vec%20-%3E%20bool&filter-crate=std
@@ -81,6 +82,7 @@ the standard library and functions that are included in the results list:
8182[ `any -> !` ] : ../../std/vec/struct.Vec.html?search=any%20-%3E%20!&filter-crate=std
8283[ stdoutu8 ] : ../../std/vec/struct.Vec.html?search=stdout%2C%20[u8]&filter-crate=std
8384[ iterasslice ] : ../../std/vec/struct.Vec.html?search=vec%3A%3Aintoiter<T>%20->%20[T]&filter-crate=std
85+ [ iterreduce ] : ../../std/index.html?search=iterator<T>%2C%20fnmut%20->%20T&filter-crate=std
8486
8587### How type-based search works
8688
@@ -95,16 +97,47 @@ After deciding which items are type parameters and which are actual types, it
9597then searches by matching up the function parameters (written before the ` -> ` )
9698and the return types (written after the ` -> ` ). Type matching is order-agnostic,
9799and allows items to be left out of the query, but items that are present in the
98- query must be present in the function for it to match.
100+ query must be present in the function for it to match. The ` self ` parameter is
101+ treated the same as any other parameter, and ` Self ` is resolved to the
102+ underlying type's name.
99103
100104Function signature searches can query generics, wrapped in angle brackets, and
101105traits will be normalized like types in the search engine if no type parameters
102106match them. For example, a function with the signature
103107` fn my_function<I: Iterator<Item=u32>>(input: I) -> usize `
104108can be matched with the following queries:
105109
106- * ` Iterator<u32> -> usize `
107- * ` Iterator -> usize `
110+ * ` Iterator<Item=u32> -> usize `
111+ * ` Iterator<u32> -> usize ` (you can leave out the ` Item= ` part)
112+ * ` Iterator -> usize ` (you can leave out iterator's generic entirely)
113+ * ` T -> usize ` (you can match with a generic parameter)
114+
115+ Each of the above queries is progressively looser, except the last one
116+ would not match ` dyn Iterator ` , since that's not a type parameter.
117+
118+ If a bound has multiple associated types, specifying the name allows you to
119+ pick which one gets matched. If no name is specified, then the query will
120+ match of any of them. For example,
121+
122+ ``` rust
123+ pub trait MyTrait {
124+ type First ;
125+ type Second ;
126+ }
127+
128+ /// This function can be found using the following search queries:
129+ ///
130+ /// MyTrait<First=u8, Second=u32> -> bool
131+ /// MyTrait<u32, First=u8> -> bool
132+ /// MyTrait<Second=u32> -> bool
133+ /// MyTrait<u32, u8> -> bool
134+ ///
135+ /// The following queries, however, will *not* match it:
136+ ///
137+ /// MyTrait<First=u32> -> bool
138+ /// MyTrait<u32, u32> -> bool
139+ pub fn my_fn (x : impl MyTrait <First = u8 , Second = u32 >) -> bool { true }
140+ ```
108141
109142Generics and function parameters are order-agnostic, but sensitive to nesting
110143and number of matches. For example, a function with the signature
@@ -134,6 +167,10 @@ Most of these limitations should be addressed in future version of Rustdoc.
134167 with that bound, it'll match, but ` option<T> -> T where T: Default `
135168 cannot be precisely searched for (use ` option<Default> -> Default ` ).
136169
170+ * Supertraits, type aliases, and Deref are all ignored. Search mostly
171+ operates on type signatures * as written* , and not as they are
172+ represented within the compiler.
173+
137174 * Type parameters match type parameters, such that ` Option<A> ` matches
138175 ` Option<T> ` , but never match concrete types in function signatures.
139176 A trait named as if it were a type, such as ` Option<Read> ` , will match
@@ -183,7 +220,8 @@ slice = OPEN-SQUARE-BRACKET [ nonempty-arg-list ] CLOSE-SQUARE-BRACKET
183220arg = [type-filter *WS COLON *WS] (path [generics] / slice / [!])
184221type-sep = COMMA/WS *(COMMA/WS)
185222nonempty-arg-list = *(type-sep) arg *(type-sep arg) *(type-sep)
186- generics = OPEN-ANGLE-BRACKET [ nonempty-arg-list ] *(type-sep)
223+ generic-arg-list = *(type-sep) arg [ EQUAL arg ] *(type-sep arg [ EQUAL arg ]) *(type-sep)
224+ generics = OPEN-ANGLE-BRACKET [ generic-arg-list ] *(type-sep)
187225 CLOSE-ANGLE-BRACKET
188226return-args = RETURN-ARROW *(type-sep) nonempty-arg-list
189227
@@ -230,6 +268,7 @@ DOUBLE-COLON = "::"
230268QUOTE = %x22
231269COMMA = ","
232270RETURN-ARROW = "->"
271+ EQUAL = "="
233272
234273ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
235274DIGIT = %x30-39
0 commit comments