Unignore Serializer::serialize_newtype_variant example
This commit is contained in:
parent
43d49f54be
commit
b9be543596
@ -476,9 +476,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. The `value` is the data contained within this newtype variant.
|
/// variant. The `value` is the data contained within this newtype variant.
|
||||||
///
|
///
|
||||||
/// ```rust,ignore
|
/// ```rust
|
||||||
/// match *self {
|
/// # use serde::{Serialize, Serializer};
|
||||||
/// E::N(ref n) => serializer.serialize_newtype_variant("E", 0, "N", n),
|
/// #
|
||||||
|
/// enum E {
|
||||||
|
/// M(String),
|
||||||
|
/// N(u8),
|
||||||
|
/// }
|
||||||
|
///
|
||||||
|
/// impl Serialize for E {
|
||||||
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
/// where S: Serializer
|
||||||
|
/// {
|
||||||
|
/// match *self {
|
||||||
|
/// E::M(ref s) => serializer.serialize_newtype_variant("E", 0, "M", s),
|
||||||
|
/// E::N(n) => serializer.serialize_newtype_variant("E", 1, "N", &n),
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_newtype_variant<T: ?Sized + Serialize>(self,
|
fn serialize_newtype_variant<T: ?Sized + Serialize>(self,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user