indexmap_amortized

Module serde_seq

Source
Expand description

Functions to serialize and deserialize an IndexMap as an ordered sequence.

The default serde implementation serializes IndexMap as a normal map, but there is no guarantee that serialization formats will preserve the order of the key-value pairs. This module serializes IndexMap as a sequence of (key, value) elements instead, in order.

This module may be used in a field attribute for derived implementations:

#[derive(Deserialize, Serialize)]
struct Data {
    #[serde(with = "indexmap_amortized::serde_seq")]
    map: IndexMap<i32, u64>,
    // ...
}

Requires crate feature "serde" or "serde-1"

Functionsยง

  • Deserializes an IndexMap from an ordered sequence.
  • Serializes an IndexMap as an ordered sequence.