Closed
Description
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).
Metadata
Metadata
Assignees
Labels
No labels