Answers for "slice indices are of type usize rust"

0

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]);
}
Posted by: Guest on October-14-2021

Browse Popular Code Answers by Language