2024-06-03 02:35:56 -05:00
|
|
|
#![crate_name = "foo"]
|
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
|
|
|
|
|
|
|
pub trait Some {}
|
|
|
|
impl Some for () {}
|
|
|
|
pub trait Other {}
|
|
|
|
impl Other for () {}
|
|
|
|
|
2024-06-03 02:35:56 -05:00
|
|
|
pub fn alef<T: Some>() -> T {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
pub fn alpha() -> impl Some {}
|
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
|
|
|
|
2024-06-03 02:35:56 -05:00
|
|
|
pub fn bet<T, U>(t: T) -> U {
|
|
|
|
loop {}
|
|
|
|
}
|
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
|
|
|
pub fn beta<T>(t: T) -> T {}
|
|
|
|
|
2024-06-03 02:35:56 -05:00
|
|
|
pub fn other<T: Other, U: Other>(t: T, u: U) {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
pub fn alternate<T: Other>(t: T, u: T) {
|
|
|
|
loop {}
|
|
|
|
}
|