Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Book section 4.8 (Ownership) v1 should be v. #34510

Closed
jonmarkprice opened this issue Jun 27, 2016 · 3 comments
Closed

Book section 4.8 (Ownership) v1 should be v. #34510

jonmarkprice opened this issue Jun 27, 2016 · 3 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@jonmarkprice
Copy link
Contributor

In section 4.8, "The details" subheading, while explaining ownership with the following code example:

let v = vec![1, 2, 3];

let mut v2 = v;

the book suddenly switches to v1 instead of v after the v2.truncate example.

It would violate Rust’s safety guarantees by introducing a data race if one could access both v and v2 at the same time.

For example if we truncated the vector to just two elements through v2:

v2.truncate(2);

and v1 were still accessible we'd end up with an invalid vector since v1 would not know that the heap data has been truncated.

The book continues to use v1 for the rest of the paragraph. But v1 does not appear in any of the preceding code segments.

@steveklabnik steveklabnik added A-docs E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. labels Jun 27, 2016
@jonmarkprice
Copy link
Contributor Author

Hmm, just checked the markdown file (ownership.md) and it's already using v (not v1). Did you already fix it or has online version not been rendered recently?

@jonmarkprice
Copy link
Contributor Author

Update: Looks like #33035 fixed this already. Closing, sorry guys.

@steveklabnik
Copy link
Member

Ah! Nice call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

2 participants