pub fn tables_last<'a, I, K, V, S>(
    data: &'a I,
    serializer: S
) -> Result<S::Ok, S::Error>where
    &'a I: IntoIterator<Item = (K, V)>,
    K: Serialize,
    V: Serialize,
    S: Serializer,
Expand description

Convenience function to serialize items in a map in an order valid with TOML.

TOML carries the restriction that keys in a table must be serialized last if their value is a table itself. This isn’t always easy to guarantee, so this helper can be used like so:

#[derive(Serialize)]
struct Manifest {
    package: Package,
    #[serde(serialize_with = "toml::ser::tables_last")]
    dependencies: HashMap<String, Dependency>,
}