6 releases

0.1.5 Sep 22, 2023
0.1.4 Apr 13, 2023
0.1.3 Oct 28, 2022
0.1.2 Aug 4, 2022
0.1.0 Jan 31, 2022

#222 in Encoding

Download history 917/week @ 2023-12-13 899/week @ 2023-12-20 1026/week @ 2023-12-27 1362/week @ 2024-01-03 1509/week @ 2024-01-10 1565/week @ 2024-01-17 1590/week @ 2024-01-24 1597/week @ 2024-01-31 1868/week @ 2024-02-07 1717/week @ 2024-02-14 1637/week @ 2024-02-21 1471/week @ 2024-02-28 1685/week @ 2024-03-06 1312/week @ 2024-03-13 1395/week @ 2024-03-20 965/week @ 2024-03-27

5,595 downloads per month
Used in 6 crates (via icu_list)

Custom license

14KB
222 lines

deduplicating_array crates.io

A serde serialization strategy that uses PartialEq to reduce serialized size.

This create can be used with Serde derive like this:


#[derive(serde::Deserialize, serde::Serialize)]
pub struct Foo {
    #[serde(with = "deduplicating_array")]
    data: [Bar; 12],
    // ...
}

Bars that are equal to a Bars that appears earlier in the array will not be serialized (instead, the index of the first occurence is serialized). Deserialization clones the first Bar into all the indices where it occurs (hence Bar has to implement Clone).

Human readable serialization represents skipped values as singleton arrays containing the target index, e.g. the Rust array ["Foo", "Bar", "Foo"] will serialize to JSON ["Foo", "Bar", [0]].

This implies that singleton integer arrays cannot be used as array elements (they do work in Bincode, but there's really not much point in using them).

More Information

For more information on development, authorship, contributing etc. please visit ICU4X home page.

Dependencies

~0.4–1MB
~24K SLoC