mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-14 16:21:03 +00:00
Unignore Serializer::serialize_struct_variant example
This commit is contained in:
+14
-1
@@ -771,7 +771,18 @@ 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
|
||||||
|
/// use serde::{Serialize, Serializer};
|
||||||
|
/// use serde::ser::SerializeStructVariant;
|
||||||
|
///
|
||||||
|
/// enum E {
|
||||||
|
/// S { r: u8, g: u8, b: u8 }
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// impl Serialize for E {
|
||||||
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
/// where S: Serializer
|
||||||
|
/// {
|
||||||
/// match *self {
|
/// match *self {
|
||||||
/// E::S { ref r, ref g, ref b } => {
|
/// E::S { ref r, ref g, ref b } => {
|
||||||
/// let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?;
|
/// let mut sv = serializer.serialize_struct_variant("E", 0, "S", 3)?;
|
||||||
@@ -781,6 +792,8 @@ pub trait Serializer: Sized {
|
|||||||
/// sv.end()
|
/// sv.end()
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_struct_variant(self,
|
fn serialize_struct_variant(self,
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
|
|||||||
Reference in New Issue
Block a user