optimise serialize
This commit is contained in:
parent
80c3582531
commit
5504f6c854
|
@ -520,8 +520,18 @@ mod serde {
|
|||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where S: ser::Serializer
|
||||
{
|
||||
struct FormatWrapped<'a, D: 'a> {
|
||||
inner: &'a D
|
||||
}
|
||||
|
||||
impl<'a, D: fmt::Debug> fmt::Display for FormatWrapped<'a, D> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.inner.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
// Debug formatting is correct RFC3339, and it allows Zulu.
|
||||
serializer.serialize_str(&format!("{:?}", self))
|
||||
serializer.collect_str(&FormatWrapped { inner: &self })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1570,7 +1570,17 @@ mod serde {
|
|||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where S: ser::Serializer
|
||||
{
|
||||
serializer.serialize_str(&format!("{:?}", self))
|
||||
struct FormatWrapped<'a, D: 'a> {
|
||||
inner: &'a D
|
||||
}
|
||||
|
||||
impl<'a, D: fmt::Debug> fmt::Display for FormatWrapped<'a, D> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.inner.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
serializer.collect_str(&FormatWrapped { inner: &self })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1468,7 +1468,17 @@ mod serde {
|
|||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where S: ser::Serializer
|
||||
{
|
||||
serializer.serialize_str(&format!("{:?}", self))
|
||||
struct FormatWrapped<'a, D: 'a> {
|
||||
inner: &'a D
|
||||
}
|
||||
|
||||
impl<'a, D: fmt::Debug> fmt::Display for FormatWrapped<'a, D> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
self.inner.fmt(f)
|
||||
}
|
||||
}
|
||||
|
||||
serializer.collect_str(&FormatWrapped { inner: &self })
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1346,7 +1346,7 @@ mod serde {
|
|||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||
where S: ser::Serializer
|
||||
{
|
||||
serializer.serialize_str(&format!("{:?}", self))
|
||||
serializer.collect_str(&self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue