Unignore Serializer::serialize_struct_variant example

This commit is contained in:
David Tolnay
2017-04-07 10:35:42 -07:00
parent f2b230a0b8
commit b1cfa5aef5
+21 -8
View File
@@ -771,14 +771,27 @@ pub trait Serializer: Sized {
/// this variant within the enum, the `variant` is the name of the variant, /// 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. /// and the `len` is the number of data fields that will be serialized.
/// ///
/// ```rust,ignore /// ```rust
/// match *self { /// use serde::{Serialize, Serializer};
/// E::S { ref r, ref g, ref b } => { /// use serde::ser::SerializeStructVariant;
/// let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?; ///
/// sv.serialize_field("r", r)?; /// enum E {
/// sv.serialize_field("g", g)?; /// S { r: u8, g: u8, b: u8 }
/// sv.serialize_field("b", b)?; /// }
/// sv.end() ///
/// impl Serialize for E {
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
/// 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()
/// }
/// }
/// } /// }
/// } /// }
/// ``` /// ```