Disambiguation in size_of

โš“ Rust    ๐Ÿ“… 2025-07-09    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 2      

surdeus

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Disambiguation in size_of

Reference says:

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?

6 posts - 4 participants

Read full topic

๐Ÿท๏ธ rust_feed