7 releases

0.1.6 May 28, 2024
0.1.5 Sep 22, 2023
0.1.4 Apr 13, 2023
0.1.3 Oct 28, 2022
0.1.0 Jan 31, 2022

#230 in Encoding

Download history 360/week @ 2024-07-21 472/week @ 2024-07-28 410/week @ 2024-08-04 488/week @ 2024-08-11 480/week @ 2024-08-18 378/week @ 2024-08-25 436/week @ 2024-09-01 733/week @ 2024-09-08 435/week @ 2024-09-15 568/week @ 2024-09-22 383/week @ 2024-09-29 624/week @ 2024-10-06 759/week @ 2024-10-13 516/week @ 2024-10-20 553/week @ 2024-10-27 1052/week @ 2024-11-03

2,918 downloads per month
Used in 9 crates (via icu_list)

Unicode-3.0

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.3–1MB
~22K SLoC