To create a vector of vectors in Rust, you can use a vector of vectors of a specific type.
In this example,
vector_of_vectors
with a specific data type.fn main() {
let vector_of_vectors: Vec<Vec<i32>> = vec![
vec![1, 2, 3],
vec![4, 5, 6],
vec![7, 8, 9],
];
println!("{:?}", vector_of_vectors);
}
[[1, 2, 3], [4, 5, 6], [7, 8, 9]]
In this tutorial, we learned How to create a Vector of Vectors in Rust language with well detailed examples.