Unignore Serializer::serialize_unit_variant example

This commit is contained in:
David Tolnay 2017-04-07 10:01:39 -07:00
parent 2e9cc6e98a
commit 753c711cd7
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -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,