Omitted names in a trait function


In some languages, when the implementation is not included in the original declaration site, the original declaration is not required to include a name for every variable in the declaration, for example in c++:

class b {
    void c(int);   

Is there any reason that I can’t do that in a trait in rust? Or is it ‘just because’?

pub trait b{
    fn c(usize);

Will not compile…


This was changed recently (for the 2018 edition) because the Rust team wanted it to be more clear what this variable is used for. This sort of information should be in the variable name.

// This works    
pub trait b{
    fn c(_: usize);

I think that in edition 2018 the parameter requires a name, even if is “_”

No more anonymous trait parameters


This also came up on internals recently:


It makes sense that there would be a push to make the docs and crates more readable by forcing trait function parameters names, thanks for the explanation!