Skip to content

Foo::<> does not use type parameter defaults #36980

Description

@bluss

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)]pubstructTest<X = String,Y = String>{x:X,y:Y,}fnmain(){// both explicitlet s = Test::<f32,f32>::default();// use default for secondlet 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();}

playground link

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-docsArea: 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.T-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions