Deriving Deserialize on Structs as Arrays


Was watching Decrusted: Serde and found out when you derive #[serde(Deserialize, Serialize)] it can be to an array as opposed to a mapping of some key:value.

This is especially helpful as I've got some little automations which query Fastmail via jmap which heavily utilizes arrays for defining what query to run.


#[derive(serde::Deserialize, serde::Serialize)]
struct RGB {
  r: u64,
  g: u64,
  b: u64

can correctly deserialize [12,222,55] into a Rust struct with named fields!