2023-09-09 18:49:29 -05:00
|
|
|
// ignore-order
|
|
|
|
|
rustdoc-search: add support for type parameters
When writing a type-driven search query in rustdoc, specifically one
with more than one query element, non-existent types become generic
parameters instead of auto-correcting (which is currently only done
for single-element queries) or giving no result. You can also force a
generic type parameter by writing `generic:T` (and can force it to not
use a generic type parameter with something like `struct:T` or whatever,
though if this happens it means the thing you're looking for doesn't
exist and will give you no results).
There is no syntax provided for specifying type constraints
for generic type parameters.
When you have a generic type parameter in a search query, it will only
match up with generic type parameters in the actual function, not
concrete types that match, not concrete types that implement a trait.
It also strictly matches based on when they're the same or different,
so `option<T>, option<U> -> option<U>` matches `Option::and`, but not
`Option::or`. Similarly, `option<T>, option<T> -> option<T>`` matches
`Option::or`, but not `Option::and`.
2023-06-16 16:43:28 -05:00
|
|
|
const FILTER_CRATE = "std";
|
|
|
|
|
2023-03-07 12:21:12 -06:00
|
|
|
const EXPECTED = [
|
|
|
|
{
|
2023-06-09 09:49:38 -05:00
|
|
|
'query': 'option, fnonce -> option',
|
2023-03-07 12:21:12 -06:00
|
|
|
'others': [
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'map' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2023-06-09 09:49:38 -05:00
|
|
|
'query': 'option -> default',
|
2023-03-07 12:21:12 -06:00
|
|
|
'others': [
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'unwrap_or_default' },
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'get_or_insert_default' },
|
|
|
|
],
|
|
|
|
},
|
2023-05-25 14:58:36 -05:00
|
|
|
{
|
|
|
|
'query': 'option -> []',
|
|
|
|
'others': [
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'as_slice' },
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'as_mut_slice' },
|
|
|
|
],
|
|
|
|
},
|
rustdoc-search: add support for type parameters
When writing a type-driven search query in rustdoc, specifically one
with more than one query element, non-existent types become generic
parameters instead of auto-correcting (which is currently only done
for single-element queries) or giving no result. You can also force a
generic type parameter by writing `generic:T` (and can force it to not
use a generic type parameter with something like `struct:T` or whatever,
though if this happens it means the thing you're looking for doesn't
exist and will give you no results).
There is no syntax provided for specifying type constraints
for generic type parameters.
When you have a generic type parameter in a search query, it will only
match up with generic type parameters in the actual function, not
concrete types that match, not concrete types that implement a trait.
It also strictly matches based on when they're the same or different,
so `option<T>, option<U> -> option<U>` matches `Option::and`, but not
`Option::or`. Similarly, `option<T>, option<T> -> option<T>`` matches
`Option::or`, but not `Option::and`.
2023-06-16 16:43:28 -05:00
|
|
|
{
|
|
|
|
'query': 'option<t>, option<t> -> option<t>',
|
|
|
|
'others': [
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'or' },
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'xor' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'query': 'option<t>, option<u> -> option<u>',
|
|
|
|
'others': [
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'and' },
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'zip' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
2023-09-09 18:49:29 -05:00
|
|
|
'query': 'option<t>, option<u> -> option<t>',
|
rustdoc-search: add support for type parameters
When writing a type-driven search query in rustdoc, specifically one
with more than one query element, non-existent types become generic
parameters instead of auto-correcting (which is currently only done
for single-element queries) or giving no result. You can also force a
generic type parameter by writing `generic:T` (and can force it to not
use a generic type parameter with something like `struct:T` or whatever,
though if this happens it means the thing you're looking for doesn't
exist and will give you no results).
There is no syntax provided for specifying type constraints
for generic type parameters.
When you have a generic type parameter in a search query, it will only
match up with generic type parameters in the actual function, not
concrete types that match, not concrete types that implement a trait.
It also strictly matches based on when they're the same or different,
so `option<T>, option<U> -> option<U>` matches `Option::and`, but not
`Option::or`. Similarly, `option<T>, option<T> -> option<T>`` matches
`Option::or`, but not `Option::and`.
2023-06-16 16:43:28 -05:00
|
|
|
'others': [
|
2023-09-09 18:49:29 -05:00
|
|
|
{ 'path': 'std::option::Option', 'name': 'and' },
|
rustdoc-search: add support for type parameters
When writing a type-driven search query in rustdoc, specifically one
with more than one query element, non-existent types become generic
parameters instead of auto-correcting (which is currently only done
for single-element queries) or giving no result. You can also force a
generic type parameter by writing `generic:T` (and can force it to not
use a generic type parameter with something like `struct:T` or whatever,
though if this happens it means the thing you're looking for doesn't
exist and will give you no results).
There is no syntax provided for specifying type constraints
for generic type parameters.
When you have a generic type parameter in a search query, it will only
match up with generic type parameters in the actual function, not
concrete types that match, not concrete types that implement a trait.
It also strictly matches based on when they're the same or different,
so `option<T>, option<U> -> option<U>` matches `Option::and`, but not
`Option::or`. Similarly, `option<T>, option<T> -> option<T>`` matches
`Option::or`, but not `Option::and`.
2023-06-16 16:43:28 -05:00
|
|
|
{ 'path': 'std::option::Option', 'name': 'zip' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'query': 'option<t>, option<u> -> option<t, u>',
|
|
|
|
'others': [
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'zip' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'query': 'option<t>, e -> result<t, e>',
|
|
|
|
'others': [
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'ok_or' },
|
|
|
|
{ 'path': 'std::result::Result', 'name': 'transpose' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'query': 'result<option<t>, e> -> option<result<t, e>>',
|
|
|
|
'others': [
|
|
|
|
{ 'path': 'std::result::Result', 'name': 'transpose' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'query': 'option<t>, option<t> -> bool',
|
|
|
|
'others': [
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'eq' },
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
'query': 'option<option<t>> -> option<t>',
|
|
|
|
'others': [
|
|
|
|
{ 'path': 'std::option::Option', 'name': 'flatten' },
|
|
|
|
],
|
|
|
|
},
|
2023-08-05 13:22:21 -05:00
|
|
|
{
|
|
|
|
'query': 'option<t>',
|
|
|
|
'returned': [
|
|
|
|
{ 'path': 'std::result::Result', 'name': 'ok' },
|
|
|
|
],
|
|
|
|
},
|
2023-03-07 12:21:12 -06:00
|
|
|
];
|