serde-rs / serde

Serialization framework for Rust
https://serde.rs/
Apache License 2.0
8.81k stars 747 forks source link

I cant Deserialize a length more than 32 array #2723

Closed v200123 closed 3 months ago

v200123 commented 3 months ago

for example,i have a strct field ” m_weather_forecast_samples: [WeatherForecastSample; 32] “,then when i build it,it will give me a error:

the trait bound `[WeatherForecastSample; 33]: Deserialize<'_>` is not satisfied
    --> src\eventModel.rs:226:33
     |
226  |     m_weather_forecast_samples: [WeatherForecastSample; 33],   // Array of weather forecast samples
     |                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Deserialize<'_>` is not implemented for `[WeatherForecastSample; 33]`
     |
     = help: the following other types implement trait `Deserialize<'de>`:
               [T; 0]
               [T; 1]
               [T; 2]
               [T; 3]
               [T; 4]
               [T; 5]
               [T; 6]
               [T; 7]
             and 26 others
note: required by a bound in `next_element`
    --> C:\Users\lc\.cargo\registry\src\index.crates.io-6f17d22bba15001f\serde-1.0.197\src\de\mod.rs:1726:12
     |
1724 |     fn next_element<T>(&mut self) -> Result<Option<T>, Self::Error>
     |        ------------ required by a bound in this associated function
1725 |     where
1726 |         T: Deserialize<'de>,
     |            ^^^^^^^^^^^^^^^^ required by this bound in `SeqAccess::next_element`

what happen?

oli-obk commented 3 months ago

We only implement the serialization traits for arrays up to length 32.

Supporting all array lengths is not easy, see https://github.com/serde-rs/serde/issues/1937 for details