serde-tuple-vec-map

Crates.ioserde-tuple-vec-map
lib.rsserde-tuple-vec-map
version1.0.1
sourcesrc
created_at2017-03-28 08:24:20.930879
updated_at2022-04-04 08:37:48.062262
descriptionDeserialize a serialized map to a Vec<(K, V)> in serde
homepage
repositoryhttps://github.com/daboross/serde-tuple-vec-map/
max_upload_size
id9178
size12,323
(daboross)

documentation

https://docs.rs/tuple-vec-map/

README

serde-tuple-vec-map

Build Status crates.io version badge

Deserialize maps or JSON objects in serde to a vec of tuples rather than a HashMap for when you're only ever going to iterate over the result.

Usage:

// replace this:
#[derive(Serialize, Deserialize)]
struct MyStuff {
    data: HashMap<KeyType, ValueType>,
}

// with this:
#[derive(Serialize, Deserialize)]
struct MyStuff {
    #[serde(with = "tuple_vec_map")]
    data: Vec<(KeyType, ValueType)>,
}

The serialized format remains exactly the same, the only difference is in how the data is decoded in Rust.

serde-tuple-vec-map supports no_std builds by using Vec defined in the alloc crate. If you're on rust 1.36.0 or newer, you can enable this with default-features=false:

[dependencies.serde-tuple-vec-map]
version = "1"
default-features = false

Note: This crate is complete, and passively maintained. It depends solely on serde and features present in stable rust. The minimum supported rust version 1.13.0 when using default features, and 1.36.0 for default-features = false.

Full usage example in tests/integration.rs, documentation at https://docs.rs/serde-tuple-vec-map.

Commit count: 44

cargo fmt