I've the below 2d vector, how can I push/insert data into it.
main(){
let mut 2d_vec: Vec<Vec<f64>> = Vec::new();
// let mut 2d_vec = vec![vec![0.0f64; columns as usize]; rows as usize];
2d_vec[w][h] = [1.0, 2.0];
}
I got this error:
error[E0277]: the type `[std::vec::Vec<f64>]` cannot be indexed by `u32`
--> src/main.rs:63:13
|
63 | 2d_vec[w][h] = [1.0, 2.0];
| ^^^^^^^^^^ slice indices are of type `usize` or ranges of `usize`
|
= help: the trait `std::slice::SliceIndex<[std::vec::Vec<f64>]>` is not implemented for `u32`
= note: required because of the requirements on the impl of `std::ops::Index<u32>` for `std::vec::Vec<std::vec::Vec<f64>>`