-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team
Description
This is about the stable Rust feature that types can have type parameter defaults.
Example code below. I expected that if Test::<T>::method
specifies one type parameter, and leaves the second to the defaulted, that Test::<>::method
should leave both type parameters to be defaulted. Instead it is equivalent to Test::method
(both type parameters inferred).
#[derive(Default)]
pub struct Test<X = String, Y = String> {
x: X,
y: Y,
}
fn main() {
// both explicit
let s = Test::<f32, f32>::default();
// use default for second
let t = Test::<i32>::default();
// use default for both?
// error[E0282]: unable to infer enough type information about `_`
let u = Test::<>::default();
// This uses the default for both.
let u2 = <Test>::default();
}
Metadata
Metadata
Assignees
Labels
A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.T-langRelevant to the language teamRelevant to the language team