How to default-initialize a struct containing an array in Rust?
问题 What is the recommended way to declare a struct that contains an array, and then create a zero-initialized instance? Here is the struct: #[derive(Default)] struct Histogram { sum: u32, bins: [u32; 256], } and the compiler error: error[E0277]: the trait bound `[u32; 256]: std::default::Default` is not satisfied --> src/lib.rs:4:5 | 4 | bins: [u32; 256], | ^^^^^^^^^^^^^^^^ the trait `std::default::Default` is not implemented for `[u32; 256]` | = help: the following implementations were found: <