@@ -72,6 +72,7 @@ the standard library and functions that are included in the results list:
72
72
| [ ` stdout, [u8] ` ] [ stdoutu8 ] | ` Stdout::write ` |
73
73
| [ ` any -> ! ` ] [ ] | ` panic::panic_any ` |
74
74
| [ ` vec::intoiter<T> -> [T] ` ] [ iterasslice ] | ` IntoIter::as_slice ` and ` IntoIter::next_chunk ` |
75
+ | [ ` iterator<T>, fnmut -> T ` ] [ iterreduce ] | ` Iterator::reduce ` and ` Iterator::find ` |
75
76
76
77
[ `usize -> vec` ] : ../../std/vec/struct.Vec.html?search=usize%20-%3E%20vec&filter-crate=std
77
78
[ `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:
81
82
[ `any -> !` ] : ../../std/vec/struct.Vec.html?search=any%20-%3E%20!&filter-crate=std
82
83
[ stdoutu8 ] : ../../std/vec/struct.Vec.html?search=stdout%2C%20[u8]&filter-crate=std
83
84
[ 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
84
86
85
87
### How type-based search works
86
88
@@ -95,16 +97,23 @@ After deciding which items are type parameters and which are actual types, it
95
97
then searches by matching up the function parameters (written before the ` -> ` )
96
98
and the return types (written after the ` -> ` ). Type matching is order-agnostic,
97
99
and 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.
99
103
100
104
Function signature searches can query generics, wrapped in angle brackets, and
101
105
traits will be normalized like types in the search engine if no type parameters
102
106
match them. For example, a function with the signature
103
107
` fn my_function<I: Iterator<Item=u32>>(input: I) -> usize `
104
108
can be matched with the following queries:
105
109
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.
108
117
109
118
Generics and function parameters are order-agnostic, but sensitive to nesting
110
119
and number of matches. For example, a function with the signature
@@ -183,7 +192,8 @@ slice = OPEN-SQUARE-BRACKET [ nonempty-arg-list ] CLOSE-SQUARE-BRACKET
183
192
arg = [type-filter *WS COLON *WS] (path [generics] / slice / [!])
184
193
type-sep = COMMA/WS *(COMMA/WS)
185
194
nonempty-arg-list = *(type-sep) arg *(type-sep arg) *(type-sep)
186
- generics = OPEN-ANGLE-BRACKET [ nonempty-arg-list ] *(type-sep)
195
+ generic-arg-list = *(type-sep) arg [ EQUAL arg ] *(type-sep arg [ EQUAL arg ]) *(type-sep)
196
+ generics = OPEN-ANGLE-BRACKET [ generic-arg-list ] *(type-sep)
187
197
CLOSE-ANGLE-BRACKET
188
198
return-args = RETURN-ARROW *(type-sep) nonempty-arg-list
189
199
@@ -230,6 +240,7 @@ DOUBLE-COLON = "::"
230
240
QUOTE = %x22
231
241
COMMA = ","
232
242
RETURN-ARROW = "->"
243
+ EQUAL = "="
233
244
234
245
ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
235
246
DIGIT = %x30-39
0 commit comments