How to create a 2D array in Rust and dynamically fill it in with Structs?
15:10 04 May 2026

I have defined a struct with four variables. This struct represents a data point for an hour. I want to collect and group hourly data for a week. Therefore I need a 7x24 array. Each day is an array of type Struct. However, I am having problems instantiating this.

I tried the approach from this answer; however, this only creates a vector of struct and not a 2 dimensional array.

Ideally I would like something that could be accessed as such:

array[daily_counter][hourly_counter].push(hour_data);
arrays rust