mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-26 03:57:56 +00:00
Unignore Serializer::serialize_newtype_struct example
This commit is contained in:
+12
-2
@@ -452,8 +452,18 @@ pub trait Serializer: Sized {
|
||||
/// wrappers around the data they contain. A reasonable implementation would
|
||||
/// be to forward to `value.serialize(self)`.
|
||||
///
|
||||
/// ```rust,ignore
|
||||
/// serializer.serialize_newtype_struct("Millimeters", &self.0)
|
||||
/// ```rust
|
||||
/// # use serde::{Serialize, Serializer};
|
||||
/// #
|
||||
/// struct Millimeters(u8);
|
||||
///
|
||||
/// impl Serialize for Millimeters {
|
||||
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
/// where S: Serializer
|
||||
/// {
|
||||
/// serializer.serialize_newtype_struct("Millimeters", &self.0)
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
fn serialize_newtype_struct<T: ?Sized + Serialize>(self,
|
||||
name: &'static str,
|
||||
|
||||
Reference in New Issue
Block a user