Description
As a new rust user I have struggled with a little problem: http://stackoverflow.com/questions/30540419/rust-ownership-copy-clone-trait
The ownership and borrowing rules are well explained in the docs but the copy trait and the types that implement them are not!
In the doc http://doc.rust-lang.org/std/marker/trait.Copy.html primitive types are not listed as copy trait implementors. They should at least be mentioned there.
It would be good to also add a little more info here: http://doc.rust-lang.org/book/ownership.html#copy-types Maybe give some examples like in my question on stackoverflow:
The following two snippets of code only compile because
i32
andbool
types both implement the copy trait. Meaning that the ownership is not moved by default but copied insteadfn main() { let a = 5; let _y = double(a); println!("{}", a); } fn double(x: i32) -> i32 { x * 2 }fn main() { let a = true; let _y = change_truth(a); println!("{}", a); } fn change_truth(x: bool) -> bool { !x }
This is very important since it is an exception to the most important rule of the language
Let me know if I have to make a pull request with a "change proposal" :)