| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; |
| 5 |
|
| 6 |
use serde::{Serialize, Serializer}; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
pub fn stabilize_hashset_serialization<S, V>(set: &HashSet<V>, s: S) -> Result<S::Ok, S::Error> |
| 11 |
where |
| 12 |
S: Serializer, |
| 13 |
V: Ord + serde::Serialize, |
| 14 |
{ |
| 15 |
let stabilized: BTreeSet<&V> = set.iter().collect(); |
| 16 |
stabilized.serialize(s) |
| 17 |
} |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
pub fn stabilize_hashmap_serialization<S, K, V>( |
| 22 |
set: &HashMap<K, V>, |
| 23 |
s: S, |
| 24 |
) -> Result<S::Ok, S::Error> |
| 25 |
where |
| 26 |
S: Serializer, |
| 27 |
K: Ord + Serialize, |
| 28 |
V: Serialize, |
| 29 |
{ |
| 30 |
let stabilized: BTreeMap<&K, &V> = set.iter().collect(); |
| 31 |
stabilized.serialize(s) |
| 32 |
} |