mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 23:01:01 +00:00
Unignore Serializer::serialize_tuple_struct example
This commit is contained in:
+17
-6
@@ -614,12 +614,23 @@ pub trait Serializer: Sized {
|
|||||||
/// The `name` is the name of the tuple struct and the `len` is the number
|
/// The `name` is the name of the tuple struct and the `len` is the number
|
||||||
/// of data fields that will be serialized.
|
/// of data fields that will be serialized.
|
||||||
///
|
///
|
||||||
/// ```rust,ignore
|
/// ```rust
|
||||||
/// let mut ts = serializer.serialize_tuple_struct("Rgb", 3)?;
|
/// use serde::{Serialize, Serializer};
|
||||||
/// ts.serialize_field(&self.0)?;
|
/// use serde::ser::SerializeTupleStruct;
|
||||||
/// ts.serialize_field(&self.1)?;
|
///
|
||||||
/// ts.serialize_field(&self.2)?;
|
/// struct Rgb(u8, u8, u8);
|
||||||
/// ts.end()
|
///
|
||||||
|
/// impl Serialize for Rgb {
|
||||||
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
/// where S: Serializer
|
||||||
|
/// {
|
||||||
|
/// let mut ts = serializer.serialize_tuple_struct("Rgb", 3)?;
|
||||||
|
/// ts.serialize_field(&self.0)?;
|
||||||
|
/// ts.serialize_field(&self.1)?;
|
||||||
|
/// ts.serialize_field(&self.2)?;
|
||||||
|
/// ts.end()
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
fn serialize_tuple_struct(self,
|
fn serialize_tuple_struct(self,
|
||||||
name: &'static str,
|
name: &'static str,
|
||||||
|
|||||||
Reference in New Issue
Block a user