add impls for {Hash,Tree}Sets
This commit is contained in:
parent
8d188747b8
commit
00c01944cf
28
src/de.rs
28
src/de.rs
@ -8,7 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::collections::{HashMap, TreeMap};
|
use std::collections::{HashMap, HashSet, TreeMap, TreeSet};
|
||||||
use std::gc::{GC, Gc};
|
use std::gc::{GC, Gc};
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::num;
|
use std::num;
|
||||||
@ -588,6 +588,32 @@ impl<
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
impl<
|
||||||
|
T: Deserializable + Eq + Hash
|
||||||
|
> Deserializable for HashSet<T> {
|
||||||
|
#[inline]
|
||||||
|
fn deserialize_token<
|
||||||
|
D: Deserializer<E>,
|
||||||
|
E
|
||||||
|
>(d: &mut D, token: Token) -> Result<HashSet<T>, E> {
|
||||||
|
d.expect_seq(token)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<
|
||||||
|
T: Deserializable + Ord
|
||||||
|
> Deserializable for TreeSet<T> {
|
||||||
|
#[inline]
|
||||||
|
fn deserialize_token<
|
||||||
|
D: Deserializer<E>,
|
||||||
|
E
|
||||||
|
>(d: &mut D, token: Token) -> Result<TreeSet<T>, E> {
|
||||||
|
d.expect_seq(token)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
macro_rules! peel {
|
macro_rules! peel {
|
||||||
($name:ident, $($other:ident,)*) => (impl_deserialize_tuple!($($other,)*))
|
($name:ident, $($other:ident,)*) => (impl_deserialize_tuple!($($other,)*))
|
||||||
}
|
}
|
||||||
|
28
src/ser.rs
28
src/ser.rs
@ -8,7 +8,7 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
use std::collections::{HashMap, TreeMap};
|
use std::collections::{HashMap, HashSet, TreeMap, TreeSet};
|
||||||
use std::gc::Gc;
|
use std::gc::Gc;
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
@ -240,6 +240,32 @@ impl<
|
|||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
impl<
|
||||||
|
T: Serializable + Eq + Hash
|
||||||
|
> Serializable for HashSet<T> {
|
||||||
|
#[inline]
|
||||||
|
fn serialize<
|
||||||
|
S: Serializer<E>,
|
||||||
|
E
|
||||||
|
>(&self, s: &mut S) -> Result<(), E> {
|
||||||
|
s.serialize_seq(self.iter())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<
|
||||||
|
T: Serializable + Ord
|
||||||
|
> Serializable for TreeSet<T> {
|
||||||
|
#[inline]
|
||||||
|
fn serialize<
|
||||||
|
S: Serializer<E>,
|
||||||
|
E
|
||||||
|
>(&self, s: &mut S) -> Result<(), E> {
|
||||||
|
s.serialize_seq(self.iter())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
macro_rules! peel {
|
macro_rules! peel {
|
||||||
($name:ident, $($other:ident,)*) => (impl_serialize_tuple!($($other,)*))
|
($name:ident, $($other:ident,)*) => (impl_serialize_tuple!($($other,)*))
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user