3 ms·
Copy is a trait that is automatically implemented by the compiler (and cannot be manually overridden) that basically just says "semantically this type can be co
by dbaupp 13y ago
Copy is a trait that is automatically implemented by the compiler (and cannot be manually overridden) that basically just says "semantically this type can be copied with memcpy", it doesn't actually control the runtime behaviour of =. Passing around a Copy type by-value leaves the source still usable ("a copy"), any other type leaves the source unusable at compile-time ("a move"); assignment is just a normal by-value use of the right-hand side. (The phrasing in that section isn't as clear as it could be.)
They are templates with checking at the declaration, not the instantiations, so you don't get the errors nested deep inside libraries with ridiculous chains of messages.
Don't knock the semicolon thing until you try it, it's actually pretty nice. :)
- fooyc 13y ago> Copy is a trait that is automatically implemented by the compiler (and cannot be manually overridden) that basically just says "semantically this type can be copied with memcpy", it doesn't actually control the runtime behaviour of =. (The phrasing in that section isn't as clear as it could be.) That's a very good news. Indeed that section is not clear, it looks like user defined classes could implement the copy trait, which would be really bad. Thanks for your answers.
- dbaupp 13y ago(BTW, I edited some more details about copy vs. move into my previous comment just after you replied.)