Release notes


  • Remove #![feature(proc_macro)] feature gates to support serde_derive on the beta channel!
  • Support deserializing a ByteBuf from a string (#645)


  • Implement skip_serializing for enum variants (#653, thanks @shinglyu)

    enum E {

    Serialization will fail with a message if that particular variant is the one being serialized.

    "The enum variant E::C cannot be serialized"


  • Implement skip_deserializing for enum variants (#641, thanks @shinglyu)

    enum E {


Support for rustc 1.15.0-nightly (7b3eeea22 2016-11-21)


Support for rustc 1.15.0-nightly (ac635aa95 2016-11-18)


Support for rustc 1.14.0-nightly (7c69b0d5a 2016-11-01)


  • Fix possible warning when building with #![warn(unused_results)] (#599, thanks @TheCatPlusPlus)



  • Fix corrupted deserialization code being generated randomly when using serde_codegen (did not affect serde_derive) #590


  • The empty array [T; 0] now supports deserializing from formats that handle fixed-sized arrays only (#582)
  • The empty array [T; 0] no longer requires T: Default in order to deserialize (#583)


  • Update the serde_derive crate type from "rustc-macro" to "proc-macro" to match the blanket rename in Rust ( Rustc 1.14.0-nightly (6e8f92f11 2016-10-07) is the first version containing the rename.


  • Impl Serialize and Deserialize for IpAddr without requiring the unstable feature (#568)


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 for steps to set up serde_derive, or for steps to set up a hybrid serde_codegen/serde_derive approach that works on stable.

Old approach

serde_macros = "0.8"
#![feature(plugin, custom_derive)]

New approach

serde_derive = "0.8"

extern crate serde_derive;

// everything else is the same


Support for rustc 1.13.0-nightly (1265cbf4e 2016-09-15)


  • Fix faulty generated code when using a serialize_with field attribute along with a nonstandard Result type in the same module (#546)


  • Add a forward_to_deserialize! macro to simplify JSON-like Deserializer implementations that want to ignore type hints given by Deserialize (#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 and ByteBuf 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)


  • 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 and cargo support (available in Using Macros 1.1 looks like this:


serde = "0.8"
serde_derive = "0.8"



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.


Support for rustc 1.13.0-nightly (eac41469d 2016-08-30)


  • Implement ValueDeserializer for Cow<str> (#513)
  • Support maps of unknown size in MapDeserializer (#514)


  • Fixes codegen for structs that have a lifetime parameter but no generic type parameter (#507)


  • Using Syntex, serde_codegen::expand now runs with a 16 MB stack by default because the previous default was often insufficient (#494, #503)


  • Impl Serialize and Deserialize for std::time::Duration (#476)
  • Use a thread in the build script of serde_codegen to allow env vars to control the stack size (#488)


This release contains significant breaking changes compared to v0.7.x.


  • The Serializer trait has been modified to allow for streaming serialization - serializing seq and map elements before knowing what the end of the seq or map will be. (#437)
  • Reduced boilerplate (no more SeqVisitor and MapVisitor) when implementing Serialize for most types.

      // OLD API
      struct MySeqVisitor { /* ... */ }
      impl /* pages of boilerplate */
      try!(serializer.serialize_seq(MySeqVisitor::new(iter, len)));
      // NEW API
      let mut state = try!(serializer.serialize_seq(len));
      for e in iter {
          try!(serializer.serialize_seq_elt(&mut state, e));
  • The Serializer and Deserializer traits no longer provide default implementations for any methods. The old defaults were JSON-centric and inappropriate for most other formats. Every Serializer and Deserializer should mindfully implement all of the methods. (#437, #452)


  • No more public dependency on Syntex. The serde_codegen::register function which was deprecated in v0.7.9 has been removed. Users should use serde_codegen::expand. See the readme for sample code, and see this forum topic for exposition. (#445)
  • Adjusted heuristic for generating bounds on generic type parameters (#456). This fixes a number of issues relating to bounds on recursive types, bounds involving references, and bounds involving private types (#435, #436, #441, #443)


  • The Deserialize impl for PhantomData<T> has been expanded to all T, not just T: Deserialize (#457, #459)
  • Add Deserialize impl for Box<str> (#454)


  • The nightly feature has been renamed to unstable to align with community practices. (#404)