Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

slice indices are of type usize rust

// note: slice indices are of type `usize`

let numbers: Vec<i32> = vec!(1,2,3,4);

// Use the operator "as usize" to index inside a for loop or similar.
for i in 0..4 {
	println!("{}", numbers[i as usize]);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #slice #indices #type #usize #rust
ADD COMMENT
Topic
Name
6+3 =