Skip to content

Clarify in the book that indexing into a vector must be done with a usize #28693

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

Closed
bstrie opened this issue Sep 27, 2015 · 0 comments
Closed

Comments

@bstrie
Copy link
Contributor

bstrie commented Sep 27, 2015

Someone came into the channel today confused at how to index into a vector. Their problem was that the variable that they wanted to use as an index was an i8. Casting actually crossed their mind, but they gave up after trying v[foo as i32] and v[foo as isize]. The page at http://doc.rust-lang.org/stable/book/vectors.html could stand to have a sentence mentioning how to index with a variable (currently it just indexes with constants, which all properly get inferred to usize without the reader realizing).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant