mirror of
https://github.com/serde-rs/serde.git
synced 2025-09-30 14:31:53 +00:00
Example for serialize_unit
This commit is contained in:
parent
2afbffa924
commit
e4b21e6caa
@ -772,6 +772,25 @@ pub trait Serializer: Sized {
|
|||||||
T: Serialize;
|
T: Serialize;
|
||||||
|
|
||||||
/// Serialize a `()` value.
|
/// Serialize a `()` value.
|
||||||
|
///
|
||||||
|
/// ```rust
|
||||||
|
/// # #[macro_use]
|
||||||
|
/// # extern crate serde;
|
||||||
|
/// #
|
||||||
|
/// # use serde::Serializer;
|
||||||
|
/// #
|
||||||
|
/// # __private_serialize!();
|
||||||
|
/// #
|
||||||
|
/// impl Serialize for () {
|
||||||
|
/// fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
|
/// where S: Serializer
|
||||||
|
/// {
|
||||||
|
/// serializer.serialize_unit()
|
||||||
|
/// }
|
||||||
|
/// }
|
||||||
|
/// #
|
||||||
|
/// # fn main() {}
|
||||||
|
/// ```
|
||||||
fn serialize_unit(self) -> Result<Self::Ok, Self::Error>;
|
fn serialize_unit(self) -> Result<Self::Ok, Self::Error>;
|
||||||
|
|
||||||
/// Serialize a unit struct like `struct Unit` or `PhantomData<T>`.
|
/// Serialize a unit struct like `struct Unit` or `PhantomData<T>`.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user