Complete the code to create a vector with three integers.
let numbers = Vec::[1]([1, 2, 3]);
The Vec::from function creates a vector from an array.
Complete the code to declare an array of five integers.
let arr: [i32; 5] = [1];
An array in Rust is declared with square brackets and a fixed size. Here, five integers are listed.
Fix the error in comparing a vector and an array for equality.
let v = vec![1, 2, 3]; let a = [1, 2, 3]; let are_equal = v [1] a;
In Rust, you can compare a vector and an array directly with == because vectors implement comparison with slices.
Fill both blanks to create a vector from an array and check if they are equal.
let arr = [10, 20, 30]; let vec = Vec::[1](arr); let equal = vec [2] arr;
Vec::from converts an array to a vector, and == compares them for equality.
Fill all three blanks to create an array, convert it to a vector, and compare their lengths.
let arr: [i32; 4] = [1]; let vec = Vec::from(arr); let same_length = vec.[2]() == arr.[3]();
len().The array is declared with four elements. Both vector and array have a len() method to get their length for comparison.
