rust-lang / nomicon

The Dark Arts of Advanced and Unsafe Rust Programming
https://doc.rust-lang.org/nomicon/
Apache License 2.0
1.79k stars 261 forks source link

Add cloning example for dot operator behaviour #292

Closed zeramorphic closed 3 years ago

zeramorphic commented 3 years ago

This contribution outlines the semantics of the dot operator and how method lookup actually works, as well as two worked examples of how the method lookup algorithm's semantics differ from how we might intuitively understand the type checker to work.

Factual content from this contribution has been sourced mainly from the dev guide, after being introduced to the topic by this answer on StackOverflow.

Signed-off-by: thirdsgames thirdsgames2018@gmail.com

JohnTitor commented 3 years ago

cc @Gankra you might want to take a look.

zeramorphic commented 3 years ago

I'm also going to edit the file to be one sentence per line (#281) shortly.

zeramorphic commented 3 years ago

Sorry, this is my first contribution here - not sure what I'm supposed to do now, but I've implemented all the changes you suggested.