Closed
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();
}