Add example usage to Formatter Serializer impl
This commit is contained in:
parent
1b8ebf6b64
commit
b7cfe33101
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user