Add example usage to Formatter Serializer impl

This commit is contained in:
David Tolnay 2020-05-09 17:42:25 -07:00
parent 1b8ebf6b64
commit b7cfe33101
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -17,6 +17,23 @@ macro_rules! fmt_primitives {
};
}
/// ```edition2018
/// use serde::Serialize;
/// use std::fmt::{self, Display};
///
/// #[derive(Serialize)]
/// #[serde(rename_all = "kebab-case")]
/// pub enum MessageType {
/// StartRequest,
/// EndRequest,
/// }
///
/// impl Display for MessageType {
/// fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
/// self.serialize(f)
/// }
/// }
/// ```
impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
type Ok = ();
type Error = fmt::Error;