Several situations often occur which result in ambiguities about the receiver or referent of method or associated function calls. These situations may include:
Multiple in-scope traits define methods with the same name for the same types
Auto-deref is undesirable; for example, distinguishing between methods on a smart pointer itself and the pointer’s referent
Methods which take no arguments, like default(), and return properties of a type, like size_of()
I really don't understand. Is the third point a subset of the first one? If yes, why is it separated? If not, what exactly does it mean? Why should that method have no arguments and return a property of the type? Could you provide examples for this?
The third bullet is separate to emphasize that even specifying the full path of the function name for ::std::mem::size_of doesn't fully specify the function used, because of the type argument.
You'd need to specify the type argument like so: std::mem::size_of::<u8>()
Technically, it's not one function, but a family of functions - one function for each T in size_of::<T>. In particular, you can't assign it to a variable of type fn() -> _, unless you specify the type - playground.
Methods which take no arguments, like default(), and return properties of a type, like size_of()
If so, my advice is to just ignore the part that talks about size_of. This section of the reference is talking about the qualified paths introduced by RFC 132. As they say, it's used for methods and associated functions. But size_of is not a method or associated function of some type.[1]
Or in other words, that bullet should probably just be
The RFC used some imaginary SizeOf trait as an example case. Perhaps this is the origin of mentioning size_of in this section?
If your confusion is about the function std::mem::size_of itself, or about the method Default::default, I'm afraid I'm still struggling to understand exactly what you find confusing.
You may need to disambiguate calls to size_of as well, but you do so with turbofish, not qualified paths. ↩︎