From 2e8ab23d9cb1b29037f05d00eefe7bb7859cc2d9 Mon Sep 17 00:00:00 2001 From: Maksym Vorobiov Date: Fri, 27 Dec 2019 23:10:50 +0200 Subject: [PATCH 1/2] add note about bytes serialization perfomance --- _src/field-attrs.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/_src/field-attrs.md b/_src/field-attrs.md index d0a2b984..06ea9f39 100644 --- a/_src/field-attrs.md +++ b/_src/field-attrs.md @@ -85,6 +85,16 @@ `$module::serialize` as the `serialize_with` function and `$module::deserialize` as the `deserialize_with` function. +```rust +// For some iter types custom module might significantly improve performance, +// for instance `Vec` ser/deserialized about 10x times faster with serde_bytes +#[derive(Serialize, Deserialize)] +struct Fast { + #[serde(with = "serde_bytes")] + buf: Vec +} +``` + - ##### `#[serde(borrow)]` and `#[serde(borrow = "'a + 'b + ...")]` {#borrow} Borrow data for this field from the deserializer by using zero-copy From e4f5b96e2393ebd23f0faccd6f42dc830b6c3264 Mon Sep 17 00:00:00 2001 From: Maksym Vorobiov Date: Fri, 27 Dec 2019 23:36:19 +0200 Subject: [PATCH 2/2] fix doc test --- _skeptic/Cargo.toml | 1 + _src/field-attrs.md | 2 ++ 2 files changed, 3 insertions(+) diff --git a/_skeptic/Cargo.toml b/_skeptic/Cargo.toml index a301f3a7..fc029ae2 100644 --- a/_skeptic/Cargo.toml +++ b/_skeptic/Cargo.toml @@ -18,5 +18,6 @@ serde_repr = "0.1" serde_test = "1.0" serde-transcode = "1.0" serde_yaml = "0.8" +serde_bytes = "0.11" skeptic = "0.13" void = "1.0" diff --git a/_src/field-attrs.md b/_src/field-attrs.md index 06ea9f39..602415c8 100644 --- a/_src/field-attrs.md +++ b/_src/field-attrs.md @@ -88,11 +88,13 @@ ```rust // For some iter types custom module might significantly improve performance, // for instance `Vec` ser/deserialized about 10x times faster with serde_bytes +# use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize)] struct Fast { #[serde(with = "serde_bytes")] buf: Vec } +# fn main() {} ``` - ##### `#[serde(borrow)]` and `#[serde(borrow = "'a + 'b + ...")]` {#borrow}