mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-12 21:21:02 +00:00
Unignore Serializer::serialize_struct_variant example
This commit is contained in:
+21
-8
@@ -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()
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|||||||
Reference in New Issue
Block a user