mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-12 19:01:02 +00:00
Use serialize_seq! to implement Serialize for [T]
This commit is contained in:
+6
-18
@@ -144,24 +144,6 @@ impl<T> Serialize for PhantomData<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
impl<T> Serialize for [T]
|
|
||||||
where T: Serialize,
|
|
||||||
{
|
|
||||||
#[inline]
|
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
|
||||||
where S: Serializer,
|
|
||||||
{
|
|
||||||
let mut seq = try!(serializer.serialize_seq(Some(self.len())));
|
|
||||||
for e in self {
|
|
||||||
try!(seq.serialize_element(e));
|
|
||||||
}
|
|
||||||
seq.end()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
macro_rules! array_impls {
|
macro_rules! array_impls {
|
||||||
@@ -232,6 +214,12 @@ macro_rules! serialize_seq {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T> Serialize for [T]
|
||||||
|
where T: Serialize,
|
||||||
|
{
|
||||||
|
serialize_seq!();
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(any(feature = "std", feature = "collections"))]
|
#[cfg(any(feature = "std", feature = "collections"))]
|
||||||
impl<T> Serialize for BinaryHeap<T>
|
impl<T> Serialize for BinaryHeap<T>
|
||||||
where T: Serialize + Ord
|
where T: Serialize + Ord
|
||||||
|
|||||||
Reference in New Issue
Block a user