Skip to content

Rustdoc: No mention of copy trait for primitive types #25893

Closed
@azerupi

Description

@azerupi

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 and bool types both implement the copy trait. Meaning that the ownership is not moved by default but copied instead

fn 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" :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.T-dev-toolsRelevant to the dev-tools subteam, which will review and decide on the PR/issue.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions