Releases: serde-rs/serde
v0.8.10
This release deprecates the old Serde compiler plugin serde_macros
in favor of the Macros 1.1-based implementation serde_derive
.
We do not intend to release any further version of serde_macros
, not even to fix breakage in future nightly versions. The design of Macros 1.1 is such that we do not expect to see the regular breakage with serde_derive
that we used to see with serde_macros
, as it depends on a far more limited set of unstable compiler internals.
See https://serde.rs/codegen-nightly.html for steps to set up serde_derive
, or https://serde.rs/codegen-hybrid.html for steps to set up a hybrid serde_codegen
/serde_derive
approach that works on stable.
Old approach
[dependencies]
serde_macros = "0.8"
#![feature(plugin, custom_derive)]
#![plugin(serde_macros)]
New approach
[dependencies]
serde_derive = "0.8"
#![feature(rustc_macro)]
#[macro_use]
extern crate serde_derive;
// everything else is the same
v0.8.9
v0.8.8
v0.8.7
-
Add a
forward_to_deserialize!
macro to simplify JSON-likeDeserializer
implementations that want to ignore type hints given byDeserialize
(#525)impl Deserializer for MyDeserializer { fn deserialize<V>(&mut self, visitor: V) -> Result<V::Value, Self::Error> where V: Visitor { /* ... */ } forward_to_deserialize! { bool usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 char str string unit option seq seq_fixed_size bytes map unit_struct newtype_struct tuple_struct struct struct_field tuple enum ignored_any } }
-
Add constructors for the
Bytes
andByteBuf
helpers (#520) -
Allow
MapDeserializer
to be deserialized as a sequence of pairs instead of a map (#527) -
Fix warnings in generated code for a non-unit struct with no fields (#536)
-
Minor cleanup of generated serialization code (#538)
v0.8.6
- Add a
serde_derive
crate which provides a Macros 1.1 implementation of#[derive(Serialize, Deserialize)]
(#530) - Add
serde_codegen::expand_str
which is necessary for Macros 1.1
Using Macros 1.1 requires rustc support (not in nightly yet but available in rust-lang/rust#35957) and cargo support (available in rust-lang/cargo#3064). Using Macros 1.1 looks like this:
Cargo.toml
[dependencies]
serde = "0.8"
serde_derive = "0.8"
src/main.rs
#![feature(rustc_macro)]
#[macro_use]
extern crate serde_derive;
#[derive(Serialize, Deserialize)]
struct ItWorks {
exciting: bool,
}
Advantages of this approach:
- We expect Macros 1.1 to be stabilized much sooner than the features that serde_macros relies on, so we are finally in sight of having ergonomic Serde code generation available on stable Rust.
- Even on nightly Rust, serde_derive is built in a way that is much more stable than serde_macros. It will not be affected by breaking libsyntax changes in the nightly compiler.