Are static methods on structs effectively just a nested namespace?

Is there any difference, other than namespace, between:

MyModule::MyStruct::my_static_method()

and

MyModule::my_static_method()

I can't think of any differences off the top of my head, no.

They're perhaps even more similar than I had ever previously thought; you get an interesting error message if a module and a struct share the same name (which doesn't typically happen due to the difference in naming conventions):

mod Foo { }
struct Foo { }
rustc 1.14.0 (e8a012324 2016-12-16)
error[E0428]: a module named `Foo` has already been defined in this module
 --> <anon>:2:1
  |
1 | mod Foo { }
  | ----------- previous definition of `Foo` here
2 | struct Foo { }
  | ^^^^^^^^^^^^^^ already defined
1 Like