Unignore Serializer::serialize_unit_variant example
This commit is contained in:
parent
2e9cc6e98a
commit
753c711cd7
@ -421,12 +421,23 @@ pub trait Serializer: Sized {
|
|||||||
/// this variant within the enum, and the `variant` is the name of the
|
/// this variant within the enum, and the `variant` is the name of the
|
||||||
/// variant.
|
/// variant.
|
||||||
///
|
///
|
||||||
/// A reasonable implementation would be to forward to `serialize_unit`.
|
/// ```rust
|
||||||
|
/// # use serde::{Serialize, Serializer};
|
||||||
|
/// #
|
||||||
|
/// enum E {
|
||||||
|
/// A,
|
||||||
|
/// B,
|
||||||
|
/// }
|
||||||
///
|
///
|
||||||
/// ```rust,ignore
|
/// impl Serialize for E {
|
||||||
/// match *self {
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
/// E::A => serializer.serialize_unit_variant("E", 0, "A"),
|
/// where S: Serializer
|
||||||
/// E::B => serializer.serialize_unit_variant("E", 1, "B"),
|
/// {
|
||||||
|
/// match *self {
|
||||||
|
/// E::A => serializer.serialize_unit_variant("E", 0, "A"),
|
||||||
|
/// E::B => serializer.serialize_unit_variant("E", 1, "B"),
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_unit_variant(self,
|
fn serialize_unit_variant(self,
|
||||||
|
Loading…
Reference in New Issue
Block a user