Example for serialize_unit

This commit is contained in:
David Tolnay 2017-04-13 15:20:09 -07:00
parent 2afbffa924
commit e4b21e6caa
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -772,6 +772,25 @@ pub trait Serializer: Sized {
T: Serialize;
/// 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>;
/// Serialize a unit struct like `struct Unit` or `PhantomData<T>`.