In this lesson we take a look at Arrays and the different ways of creating them. Arrays in Rust are collections of values of the same type that cannot change in size. In other words, the number of fields (or elements) has to be known at compile time.
#[allow(warnings)]
fn main() {
let names = ["Pascal", "Christoph", "Elvira"];
// type i8, length 4
let numbers: [i8; 4] = [3, 2, 1, 4];
// all values are 1, length 10,
let tenOnes = [1; 10];
for number in &numbers {
println!("{}", number);
}
}
标签:Arrays,number,length,let,type,Rust From: https://www.cnblogs.com/Answer1215/p/18024201