Array and tuple expressions
An array is a sequential collection of data values. There are many ways to use and manipulate them, but here we're interested in the specialized expressions that create them and access their internal data values. To tell Rust that we want to create a new array, all we have to do is write a [ symbol, and then a comma-separated list of expressions that produce the values we want to store in the array, and then a ] symbol. There doesn't have to be anything between the beginning and ending symbols if we want an empty array. So, we can write [] as an expression producing an empty array, or [1, 3, 5] as an expression producing an array containing three numbers. All of the values stored in an array need to have the same ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access