📜  切片索引的类型为 usize rust 代码示例

📅  最后修改于: 2022-03-11 14:49:25.930000             🧑  作者: Mango

代码示例1
// note: slice indices are of type `usize`

let numbers: Vec = 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]);
}