mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-13 20:41:02 +00:00
Add example usage to Formatter Serializer impl
This commit is contained in:
@@ -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> {
|
impl<'a, 'b> Serializer for &'a mut fmt::Formatter<'b> {
|
||||||
type Ok = ();
|
type Ok = ();
|
||||||
type Error = fmt::Error;
|
type Error = fmt::Error;
|
||||||
|
|||||||
Reference in New Issue
Block a user