From b1cfa5aef567f8eb68cb6a1d44f38dc0514e6977 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 7 Apr 2017 10:35:42 -0700 Subject: [PATCH] Unignore Serializer::serialize_struct_variant example --- serde/src/ser/mod.rs | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/serde/src/ser/mod.rs b/serde/src/ser/mod.rs index 8fafbbec..41052c6d 100644 --- a/serde/src/ser/mod.rs +++ b/serde/src/ser/mod.rs @@ -771,14 +771,27 @@ pub trait Serializer: Sized { /// this variant within the enum, the `variant` is the name of the variant, /// and the `len` is the number of data fields that will be serialized. /// - /// ```rust,ignore - /// match *self { - /// E::S { ref r, ref g, ref b } => { - /// let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?; - /// sv.serialize_field("r", r)?; - /// sv.serialize_field("g", g)?; - /// sv.serialize_field("b", b)?; - /// sv.end() + /// ```rust + /// use serde::{Serialize, Serializer}; + /// use serde::ser::SerializeStructVariant; + /// + /// enum E { + /// S { r: u8, g: u8, b: u8 } + /// } + /// + /// impl Serialize for E { + /// fn serialize(&self, serializer: S) -> Result + /// where S: Serializer + /// { + /// match *self { + /// E::S { ref r, ref g, ref b } => { + /// let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?; + /// sv.serialize_field("r", r)?; + /// sv.serialize_field("g", g)?; + /// sv.serialize_field("b", b)?; + /// sv.end() + /// } + /// } /// } /// } /// ```