Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

2 is Copy? It's an integer, could be 2.0 if you wanted to make it a float.

Someone needs to explicitly nail down the mission statement of Rust... because to me it seems to be

"Rust will introduce pointers where they don't need to be, and then try to protect you from the results with obsessive rules"



I wrote a piece that tries to explain Rust's memory management strategy, compared to C: https://fasterthanli.me/articles/declarative-memory-manageme...

Hope it helps!


Yes, primitive types all implement Copy.

Maybe playing around with the code would help you better, because that last line doesn't make any sense: https://play.rust-lang.org/?version=stable&mode=debug&editio...


You need to seriously read more on Rust before making judgments. You're clearly confused.

What '2 is Copy' means precisely that Rust WILL NOT 'introduce pointers where they don't need to be' - 2 is fine to 'alias' because it's a primitive type and so a copy is made when you do that, (i.e. the type implements the 'Copy' trait). However when you do that with complex types that do not implement Copy, you're moving ownership to the new variable so cannot use the old one any more.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: