-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Document bounds checking in the book #30310
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
Conversation
(Note: This PR doesn't add anything to the API docs yet; I'd like to do that in a follow-up issue after we work out what to put in the book.) |
println!("Item 7 is {}", v[7]); | ||
``` | ||
|
||
then the current thread will [panic][] with a message like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need the extra []s here
normally, this would be a big issue, but since we're doing a reorganization soon, it's cool. r=me with the nit |
ac55c12
to
5b9dd6a
Compare
Fixed the nit. |
@bors: r+ rollup |
📌 Commit 5b9dd6a has been approved by |
⌛ Testing commit 5b9dd6a with merge 8a68364... |
💔 Test failed - auto-mac-64-opt |
@bors: retry On Sat, Dec 12, 2015 at 12:00 AM, bors [email protected] wrote:
|
r? @steveklabnik Currently neither the API docs nor the book clearly explain that out-of-bounds array indexing causes a panic. Since this is fairly important and seems to surprise a number of new Rust programmers, I think it's worth adding to both places. (But if you think it would be better to put this info in the API docs only, that's fine too.) Some specific things I'd like feedback on: * The new text here talks about panicking, which hasn't been formally introduced at this point in chapter 5 (though it has been mentioned in previous sections too). * Similarly the `Vec::get` example uses `Option<T>` which hasn't been fully introduced yet. Should we leave out this example?
r? @steveklabnik
Currently neither the API docs nor the book clearly explain that out-of-bounds array indexing causes a panic. Since this is fairly important and seems to surprise a number of new Rust programmers, I think it's worth adding to both places. (But if you think it would be better to put this info in the API docs only, that's fine too.)
Some specific things I'd like feedback on:
Vec::get
example usesOption<T>
which hasn't been fully introduced yet. Should we leave out this example?